The parameter type of filter can be divided into two kinds
1. Pass Selector
$ (' a '). Filter ('. External ')
2. Pass Filter function
$ (' a '). Filter (function (index) {
return $ (this). Hasclass (' external ');
})
Second, the difference between find and filter in jquery
1. Find () looks for elements of class classname within the DIV element.
2. Filter () is the element that filters the div's class to classname.
3, the basic is find sub-element, filter is a lateral search
4. The Find function is queried in the child elements of the current object collection;
5, the filter function is the current object collection filtering, the use of filtering conditions to narrow the scope;
6. The parameter of the Find function is the jQuery selector expression;
7, the filter parameter is also the selector expression, but can have multiple conditions, separated by commas (logical or relationship);
8, the filter parameter can also be a function, the call function will automatically pass in the index parameter, the function should return TRUE or FALSE to select or exclude elements.
The use of filter in jquery