The use of filter in jquery

Source: Internet
Author: User
The parameter type of filter can be divided into two kinds

1. Pass Selector

$ (' a '). Filter ('. External ')



2. Pass Filter function


$ (' a '). Filter (function (index) {
return $ (this). Hasclass (' external ');
})



Second, the difference between find and filter in jquery

1. Find () looks for elements of class classname within the DIV element.
2. Filter () is the element that filters the div's class to classname.
3, the basic is find sub-element, filter is a lateral search


4. The Find function is queried in the child elements of the current object collection;
5, the filter function is the current object collection filtering, the use of filtering conditions to narrow the scope;
6. The parameter of the Find function is the jQuery selector expression;


7, the filter parameter is also the selector expression, but can have multiple conditions, separated by commas (logical or relationship);
8, the filter parameter can also be a function, the call function will automatically pass in the index parameter, the function should return TRUE or FALSE to select or exclude elements.

The use of filter in jquery

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.