Jquery gets the number of the same child under an element

  • 2020-03-30 03:36:49
  • OfStack

For example, in the following HTML code, to get the number of a elements below the P element:


<p id="father"> 
<a></a> 
<a></a> 
<a></a> 
<a></a> 
<a></a> 
 ...  
<a></a> 
</p> 

We can write it like this:


$("#father a").length

Related articles: