First, let’s look at the .find() method:
Now there is a page with the HTML code: :
If we use the find() method:
var $find = $("div").find(".rain");
alert( $find.html() ) ;
will output:
If you use the filter() method:
var $filter = $("div").filter(".rain");
alert( $filter.html() );
will be output :
Maybe you have seen the difference between them.
find() will look for elements with class rain within the div element.
And filter() filters the elements whose class is rain in div.
One is to operate on its subset, and the other is to filter the elements of its own collection.
In addition, find() can actually be represented by a selector:
var $select = $("div .rain");
Do you understand the difference between them?