What is the usage of visible in jquery

WBOY
Release: 2022-04-15 17:08:22
Original
3022 people have browsed it

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")".

What is the usage of visible in jquery

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

What is the usage of visible in jquery

: 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 )

##Syntax

$(":visible")
Copy after login

The example is as follows:


<!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>
Copy after login

Output result:

What is the usage of visible in jquery

Related video tutorial recommendations:

jQuery video tutorial

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!

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