Home  >  Article  >  Web Front-end  >  jQuery help filtering and finding children([expr])_jquery

jQuery help filtering and finding children([expr])_jquery

WBOY
WBOYOriginal
2016-05-16 18:11:16890browse

children([expr])
Gets an element set containing all child elements of each element in the matched element set.
You can filter matching child elements through optional expressions. Note: parents() will find all ancestor elements, while children() will consider child elements but not all descendant elements.
Return value: jQuery
Parameters:
expr (String): (optional) Expression used to filter child elements.
Example:
Find every child element in a DIV.
HTML code:

Copy code The code is as follows:

Hello< /p>

Hello Again

And Again



jQuery code:
Copy code The code is as follows:

$("div").children()

Result:
Copy code The code is as follows:

Hello Again

Find the class .selected in each div.
HTML code:
Copy code The code is as follows:
Hello< ;/span>

Hello Again

And Again



jQuery code:
Copy code The code is as follows:
$("div").children(".selected")


Result:
Copy code The code is as follows:

Hello Again

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