Finding a visible class element within a parent element

This question already has an answer here:

  • Detect if an element is visible [duplicate] 3 answers

  • Here's how you do it :

    $('#parent').find(':visible');
    

    jsFiddle


    你可以这样做小提琴

    $("#parentElement").children(':visible'); 
    

    Perhaps something along the lines of:

  • Get all the child class elements of the parent element

    var childElements = $("#parent .child");
    
  • Find the element you want:

    var foundIt;
    
    childElements.each(function(){ 
    
     if(this.is(':visible')){
    
        foundIt = this;
    
     }
    
    });
    
  • References:

  • https://api.jquery.com/each/

  • Detect if an element is visible

  • EDIT:

      if(this.is(':inline')){
    
            foundIt = this;
    
         }
    
    链接地址: http://www.djcxy.com/p/83534.html

    上一篇: 是否有可能让元素对jquery不可见?

    下一篇: 在父元素中查找可见的类元素