Home >Web Front-end >JS Tutorial >jquery gets the number of identical sub-elements under an element code_jquery

jquery gets the number of identical sub-elements under an element code_jquery

WBOY
WBOYOriginal
2016-05-16 16:40:331396browse

For example, the following html code needs to get the number of a elements under the P element:

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

We can write like this:

$("#father a").length
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn