jquery Filter () method

Source: Internet
Author: User

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.
  • Index -the index position of the element in the collection.

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.