jQuery :hidden Selector


The :hidden selector in jQuery is used to select all hidden elements.

Syntax

The syntax is as follows −

$(":hidden")

Example

Let us now see an example to implement the :hidden() selector −

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script>
   $(document).ready(function(){
      $("h2:hidden").show();
   });
</script>
</head>
<body>
<h2 style="display:none;">Fill the form</h2>
<form action="">
ID: <input type="text" name="id"><br>
Rank: <input type="text" name="rank"><br>
Fav. Subjects:
Maths: <input type="checkbox" name="sub" value="maths">
English <input type="checkbox" name="sub" value="english"><br>
<input type="submit" value="Submit"><br>
</form>
</body>
</html>

Output

This will produce the following output. Here, we are displaying the hidden element <h2> −

Updated on: 05-Nov-2019

158 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements