Ankush

Ankush

  • NA
  • 267
  • 62.9k

Count number of divs with same class name in a specific div in jquery

Oct 27 2020 2:02 AM
I have following divs
  1. <div class="Main">  
  2.     <div class="pipe">  
  3.         <div class="mine"></div>  
  4.         <div class="mine"></div>  
  5.         <div class="mine"></div>  
  6.     </div>  
  7.     <div class="pipe">  
  8.         <div class="mine"></div>  
  9.         <div class="mine"></div>  
  10.     </div>  
  11. </div> 
var count = $(.pipe.mine).length;
It counts all divs with class = "mine" and shows count as 5.
 
but I want to only count divs with class = "mine" in upper div not both the divs
Thanks in Advance!!!
 

Answers (7)