jQuery :hidden Selector

The jQuery :hidden selector select all the hidden elements by considering any of the below situations:

  • Element is set to a CSS property display:none.
  • Form hidden field using type="hidden".
  • When the width and height set to zero(0).
  • A hidden parent element hiding the child element as well.

If you want to select or find the hidden elements, you can use the selector. It’s not applicable to the element hidden using the CSS property like visibility:hidden or using the opacity:0.

Syntax of jQuery :hidden Selector

the syntax of the jQuery :hidden selector is given below.

Syntax
$(“:hidden”)

There is no parameter or argument you have to use with this selector. However, you have to use the element name, class or id before the keyword :hidden to select only the specified element.

Check the example below to get the find the hidden elements.

How jQuery :hidden Selector Select Hidden Elements

If you want to get the hidden element inside the div which is set to a CSS property display:none. You have to use the below example which displays the hidden element on button click. It uses the jQuery show() after selecting the element using the jQuery :hidden selector.

Example

Test it Live

Output

Welcome to Tutorialdeep!

Use codes to your project freely.

Modify and run your codes live with our editor.

Create your website with our free blog setup service.

When you click the button given above, the selector first selects the hidden element. After selecting, it displays the element using the show() with a speed of 1sec. By using the above method, you can find the hidden items from any elements of your choice.

Find Value of All Hidden Elements inside a Form

A form element may contain many hidden fields which many code may use to track the submission. The below form contains the two hidden input field with type="hidden". You can find the value of the hidden fields using the below example.

Example

Test it Live

Output







When you click the button given above, it finds the value of all the hidden element using the jQuery each(). An alert box will start appear for two times which displays the value of the hidden elements.