The difference between filter () and find () in jquery for a deeper understanding of _jquery

Source: Internet
Author: User
Tags new set
Has not been very clear the difference between the filter () method and the Find () method, today in the Reading of jquery Cookbook book, finally be made clear.

Filter () filters the DOM element wrapper set, which refers to manipulating the current element set, deleting mismatched elements, and getting a new set
Copy Code code as follows:

$ (' div '). Filter ('. Div1 ');//select div element with Div1 class attribute in div tag

Find () finds the eligible descendants in the context of the currently selected element, and returns the child element
Copy Code code as follows:

$ (' div '). Find (' em ');//Select the elements of the EM tag in the div tag

As you can see from the above, filter () is a collection of selected elements to get the elements in the element that match the criteria, and find () is the selected element

The descendant element that meets the criteria in the

Finally, we introduce an end () method to return the selection before the destructive modification
Copy Code code as follows:

$ (' div '). Filter ('. Div1 '). end ();//returns the selection element before using filter (), that is $ (' div ')
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.