The jquery filter filter (EXPR|OBJ|ELE|FN) filters out a collection of elements that match the specified expression, which is used to narrow the matching range, separating multiple expressions with commas

Source: Internet
Author: User

Filters out the collection of elements that match the specified expression, which is used to narrow the matching range, separating multiple expressions with commas

When a parameter is a function, the parameters inside the function are interpreted as follows:
A function is used as a collection of test elements. It accepts a parameter index, which is an element in the jquery collection. In the function, this refers to the current DOM element

Example: <! DOCTYPE html>

;} Html{font:15px/1.2em ' Courier New '; color: #666; width:750px;margin:25px auto;} div > p{white-space:pre-wrap;margin:15px 0;} Div>*{text-indent:8px;} . Hover{color: #FF96EC;}</style><script type= ' Text/javascript ' >    $(function(){        /*filters out the collection of elements that match the specified expression, which is used to narrow the range of matches, separating multiple expressions with commas when the argument is a function, the parameters inside the function are interpreted as follows: A function is used as a collection of test elements. It accepts a parameter index, which is an element in the jquery collection.        In the function, this refers to the current DOM element. */
$ (' div '). Filter ('. Selectordemofirst,.selectordemosecond '). addclass (' hover ');
$(' Div '). Filter (function(index) {if($( This). Hasclass (' Selectordemofirst ')) return$( This); }). addclass (' Hover ') ; });</script>

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.