The filter() method returns elements that match a certain criteria.
The filter() method is used to filter out all the elements that do not match the selected criteria and those matches will be returned.
This method is often used to narrow down the search for an element in a group of selected elements.
criteria : It specifies a selector expression, a jQuery object or one or more elements to be returned from a group of selected elements.
Tip: To specify multiple criteria, use comma.
function(index) : It specifies a function to run for each element in the set. If the function returns true, the element is kept. Otherwise, it is removed.
index : The index position of the element in the set.