简体   繁体   中英

jQuery search by class AND css value NOT equal to foo

Not sure where to look in the jQuery documentation to find this. I have a jQuery element that I found on the DOM.

Within that, I want all elements with class == 'bar' and css value 'display' == 'none' . The first part is easy:

$myElement.find(".bar");

How can I get all elements within this list where the css value 'display' == 'none' ?

All in one line if possible. Thanks!

You can use filter:

$myElement.find(".bar").filter(function(){
  return $(this).css('display') == 'none';
}).Apply_your_jQuery_method_now();

这样做:

 $myElement.find(".bar").filter(":hidden"); //you have all display:none ones

您可以使用:visible选择器

$myElement.find(".bar:not(:visible)");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM