Home > Web Front-end > Front-end Q&A > What should I do if the show() method in jquery does not work?

What should I do if the show() method in jquery does not work?

WBOY
Release: 2022-06-07 11:08:56
Original
3074 people have browsed it

In jquery, the show() method does not work because this method only applies to elements hidden through jQuery methods and "display:none" in css, and does not apply to elements hidden through "visibility:hidden" Element, just use "element.style.visibility="visible"" to make the element display.

What should I do if the show() method in jquery does not work?

The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.

What to do if the show() method in jquery does not work

Reason: show() is applicable to elements hidden through the jQuery method and display:none in CSS (not applicable through visibility:hidden hidden elements).

visibility:hidden method

The visibility attribute specifies whether the element is visible.

Even invisible elements take up space on the page. Use the "display" attribute to create invisible elements that do not take up page space.

Description

This attribute specifies whether to display the element box generated by an element. This means that the element still occupies its original space, but can be completely invisible. The value collapse is used in tables to remove columns or rows from the table layout.

The example is as follows:

<div class="curr-page" style="visibility:hidden" id="currPage"></div>//visibility:hidden表示默认隐藏
Copy after login
var currentBtn = document.getElementById("currPage");
        currentBtn.style.visibility = "visible"; //显示
var currentBtn = document.getElementById("currPage");
        currentBtn.style.visibility = "hidden"; //隐藏
Copy after login

If it is a display:none element, you can use the show method directly

If the selected element has been hidden, display these Elements:

Grammar

$(selector).show(speed,callback)
Copy after login

Examples are as follows:

<div class="curr-page" style="display:none" id="currPage"></div>  //display:none表示默认隐藏
Copy after login
 $("#currPage").show();//Jquery方法 显示 
 $("#currPage").hide(); //Jquery方法 隐藏
Copy after login

Video tutorial recommendation: jQuery video tutorial

The above is the detailed content of What should I do if the show() method in jquery does not work?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template