jQuery detect visible but hidden elements

后端 未结 3 1756
情深已故
情深已故 2020-12-29 10:17

This seems like it should be fairly easy - but I can\'t find the right selector for it

According to the docs (http://api.jquery.com/hidden-selector/ and http://api.j

3条回答
  •  有刺的猬
    2020-12-29 10:39

    If it is a specific element that you are looking for then you could check it's display property

    $('#element').css('display') != 'none';
    

    If it wasn't a specific element then you could find the parent nodes that are hidden using :hidden then use a custom function to look for nodes of the type you want. E.g.

    $('parent-selector:hidden').find('node-selector').each(function(){
      if($(this).css('display') != 'none') {
        // do what you wanted
      }
    });
    

    If you want a clean selector then i think that you're going to be out of luck as i don't think what you want is part of the CSS spec, so won't be there as a selector in jQuery.

提交回复
热议问题