jQuery find () method
Examples
Back <ul> offspring all <span> element:
$("ul").find("span").css({"color":"red","border":"2px solid red"});
});
result:
- ul (parent)
- li (child) span (grandchild)
try it"
Definition and Usage
find () method returns the selected element descendant elements.
Descendant is a child, grandson, great-grandchildren, and so on.
DOM tree: This method is traversed downward along descendant DOM elements, all paths until the last offspring (<html>). Just as the DOM tree traversal down a single hierarchy (return direct child element), use children () method.
Note: filter parameters in the find () method is required, which is different from other tree traversal methods.
Tip: To return all descendants of the elements, use the "*" selector.
grammar
参数 | 描述 |
---|---|
filter | 必需。过滤搜索后代条件的选择器表达式、元素或 jQuery 对象。 注意:如需返回多个后代,请使用逗号分隔每个表达式。 |
More examples
Back <html> all descendant elements
Use "*" selector to return <html> all descendant elements.
Back <ul> offspring all <span> element
How to Return <ul> offspring all <span> element.
Select offspring with a given class name
How to return descendant elements of the class named "1".
Return multiple offspring
How to return multiple descendant elements.
Filter search by jQuery collection of all generations <ul> element
How to Return <ul> element with jQuery object descendant all <span> element.
Presentation by descendants of the tag name of the element
Demo <div> element descendants.