JQuery find children

 

.children(selector)

Returns all immediate subordinate children (children only) of each element in the set of matched elements.

The parameter is optional, adding a parameter means filtering through the selector.

 

.find(selector)

Returns all descendants (sons, grandchildren..., up to the last descendant) of each element in the set of matched elements.

The parameter is required and is used to filter the subordinate elements.

 

Example

//Add styles to the span elements under all p elements (set to red)
$("p").find("span").css('color','red');

//Set the style for all div elements, those with the selected style, and the child elements (set to blue)
$("div").children(".selected").css("color", "blue");

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326803170&siteId=291194637