In jQuery, how can I select a hidden element?

You are looking for the :hidden selector

Please note that the proper way of selecting an element by ID is simply:

$("#test1");

Doing it the way you are doing is making jQuery do unnecessary parsing and is much slower.

If you want to select #test1 only if it is hidden, you do this:

$("#test1:hidden");

If you wanted to select all <span> elements that are hidden under #p1, you do this:

$("span:hidden", "#p1");

As noted in the comments, the opposite of this selector is the :visible selector:

$("span:visible", "#p1");

Would then select any visible <span> elements in the element #p1.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)