The filter () method in jquery allows you to specify a filtering rule where elements that do not match the criteria are removed from the collection and the matching elements are returned.
One, filter () syntax
$ (selector). Filter (criteria,function(index))
| Parameters |
Describe |
| Criteria |
Optional. Specifies the selector expression, JQuery object, one or more elements to be returned from the selected element combination.
Tip: If you want to specify multiple conditions, use a comma-delimited list. |
| Function (index) |
Optional. Specifies the function to run for each element in the collection. If true, the element is preserved, otherwise the element is removed.
Note: This is the current DOM element. |
Ii. Examples of the filter () in jquery
<ul> <li>list Item 1</li> <li>list item 2</li> <li>list Item 3</li> <LI&G T;list Item 4</li> <li>list item 5</li> <li>list item 6</li></ul><script>$ (' Li '). Filter (': even '). css (' background-color ', ' Red ');</script>
Reference: jquery Filter Method http://www.studyofnet.com/news/951.html
This article is from the "Learning also leisure" blog, please be sure to keep this source http://studyofnet.blog.51cto.com/8142094/1697586
jquery Filter () method