In jquery, the ":visible" selector is used to select each visible element; visible elements are except "display:none" style elements and form elements with "type="hidden"" , elements other than elements with width and height of 0, the syntax is "$(":visible")".
The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.
: The visible selector selects each element that is currently visible.
Elements other than the following situations are visible elements:
is set to display:none
with Form elements with type="hidden"
width and height set to 0
hidden parent elements (this will also hide child elements )
$(":visible")
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>123</title> <script src="js/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p:visible").css("background-color","yellow"); }); </script> </head> <body> <h1>这是一个标题</h1> <p>这是一个段落。</p> <p>这是另外一个段落。</p> <p style="display:none">这是一个隐藏段落。 </p> </body> </html>
The above is the detailed content of What is the usage of visible in jquery. For more information, please follow other related articles on the PHP Chinese website!