This method can filter out elements or a collection of elements that match the specified expression or method return value.
Grammar structure 1:
Filter out the set of elements that match the specified expression.
Parameter list:
Example code:
This code can set the font color in the li with the class name js to blue.
Grammar structure 2:
Filter out the specified jquery object from the element collection.
Parameter list:
Example code:
Example 1:
Example 2:
Grammar structure three:
Filter out the set of elements that match the return value of the specified function.
The filter() method will be calculated once for each object internally (such as $.each). If the called function returns false then the element is deleted, otherwise it is retained.
Parameter list:
Example code:
I hope this article will be helpful to everyone’s jQuery programming.