The jQuery is a very powerful tool which helps us to incorporate a variety of DOM traversal methods to select elements in a document randomly or in sequential order. Most of the DOM traversal methods do not modify the elements whereas they filter them out upon the given conditions. The filter() method is used to filter out all the elements that do not match the selected criteria and those matches will be returned. Syntax:
Parameters: criteria : It specifies a selector expression, a jQuery object or one or more elements to be returned from a group of selected elements. 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.
NOTE : To specify more than one criteria, use a comma.
jQuery code to show the working of the filter() method
This code will return all elements matching with selected criteria.
Please Login to comment...