This is a commonly used method in jQuery. Their two functions are completely different, and beginners are often misled. First, let's look at the. find () method:
There is a page in which the HTML code is;
The Code is as follows:
Test 1
Test 2
If we use the find () method:
Var $ find = $ ("p"). find (". rain ");
Alert (LOGIN find.html ());
The output is as follows:
If the filter () method is used:
Var $ filter = $ ("p"). filter (". rain ");
Alert (export filter.html ());
The output is as follows:
Maybe you have seen the difference between them.
Find () searches for elements whose class is rain in the p element.
Filter () is the element that filters p's class as rain.
One is to operate on its subset, and the other is to filter its own set elements.
In addition, find () can also be represented by selector:
Var $ select = $ ("p. rain ");
Do you understand their differences?