jQuery filter() Method
jQuery filter() Method
The filter() method is used to return elements that match certain criteria. It allows us to specify criteria for search. Elements that do not match the criteria are removed from the selection, and those that match will be returned.
Syntax:-
Its syntax is:- $(selector).filter(criteria, function(index))
Further Explanation:-
Parameter | Description |
---|---|
criteria | Optional. Specifies a selector expression, a jQuery object or one or more elements to be returned from a group of selected elements. |
function(index) | Optional. Specifies a function to run for each element in the set. If it returns true, the element is kept. Otherwise, the element is removed.
|