Home  >  Article  >  Web Front-end  >  Talk about the differences between children find in Jquery_jquery

Talk about the differences between children find in Jquery_jquery

WBOY
WBOYOriginal
2016-05-16 15:36:111221browse

Essence: The find method can find descendants, the children method can only find sons

1. children in Jquery

Grammar

.children(selector)

Description

expr is an expression, optional parameter. All expressions in the selector can be used here, such as by tag name "div", by class name ".class", by sequence number ":first", etc. If the expression is empty, all children are returned and the returned result is still a jQuery object.

2. Find
in Jquery

The find() method obtains the descendants of each element in the current element collection, filtered by selectors, jQuery objects, or elements.

Grammar

.find(selector)

Description

It accepts a selector expression of the same type as the expression we passed to the $() function. Elements will be filtered by testing whether they match the expression.

3. The difference between children and find in jquery

1. The children and find methods are both used to obtain the child elements of element. Neither of them will return text node, just like most jQuery methods.
2. The children method only obtains the child elements below the element
3. The find method obtains all subordinate elements
4. The parameter selector of the children method is optional (optionally) and is used to filter child elements, but the parameter selector of the find method is required.
5. The find method can actually be implemented by using jQuery (selector, context)

The above content is the editor’s introduction to the differences between children find in Jquery. I hope you like it.

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