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 ')