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.
The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.
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表示默认隐藏
var currentBtn = document.getElementById("currPage"); currentBtn.style.visibility = "visible"; //显示 var currentBtn = document.getElementById("currPage"); currentBtn.style.visibility = "hidden"; //隐藏
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)
Examples are as follows:
<div class="curr-page" style="display:none" id="currPage"></div> //display:none表示默认隐藏
$("#currPage").show();//Jquery方法 显示 $("#currPage").hide(); //Jquery方法 隐藏
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!