Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery/CSS - How do I select all the li display none in the document?

jQuery/CSS - How do I select all the <li style="display: none;"> in the document?

like image 282
Matt Avatar asked Sep 12 '11 06:09

Matt


4 Answers

While the chosen answer works in your case, it's still doesn't answer the question. Same for the answers posted by other people, so I decided to write this anyway.

$('li[style*="display: none"]')

This will return a jQuery object representing a list of all the <li> elements in your document with a style property containing "display: none".

This is a different thing that finding all the hidden elements in the document.

like image 145
Jose Faeti Avatar answered Nov 08 '22 12:11

Jose Faeti


There is a selector to find hidden elements:

$('li:hidden')

Note that this finds all li elements that are not visible, not only because they have the style display:none applied to them. The element could be hidden for example by setting their height to zero, or hiding the parent element.

like image 45
Guffa Avatar answered Nov 08 '22 13:11

Guffa


Try this

$("li").filter(function() { return $(this).css("display") == "none" })
like image 5
Allen Liu Avatar answered Nov 08 '22 13:11

Allen Liu


$('li:hidden') - Try as per jquery document it will work

Fore more dtail - :hidden Selector

like image 4
Pranay Rana Avatar answered Nov 08 '22 13:11

Pranay Rana