Home  >  Article  >  Web Front-end  >  How to search child elements with jQuery_jquery

How to search child elements with jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 16:14:401187browse

The example in this article describes how jQuery searches for child elements. Share it with everyone for your reference. The specific analysis is as follows:

1. children() method

is used to obtain an element set containing all sub-elements of each element in the matched element set. The syntax format is as follows:

Copy code The code is as follows:
children([selector])
$("#menu_ul").children().css("color", "blue");

2. find() method

is used to find descendant elements that match the specified selector expression from each matching element. The format is as follows:

Copy code The code is as follows:
find([selector])
$("ul").find("span").css("color", "blue");//Set the text element of the span element under the ul element to blue

The sample code is as follows:

Copy code The code is as follows:




Search for child elements of the specified element




Search for child elements of the specified element




​​​​​ Username:
Password:
& Lt; div & gt; & lt; input type = "submit" value = "login"/& gt; & lt; input type = "reset" value = "reset"/& gt;/div & gt;























Cell Cell
Cell Cell
Cell Cell
Cell Cell
Cell Cell




The rendering is as follows:

I hope this article will be helpful to everyone’s jQuery programming.

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