Step-by-step learning JQuery (c) Filter selector: Basic Filter Selector && Content Filter Selector && Visibility Filter Selector

Source: Internet
Author: User

Filter Selector :

The filter selector primarily filters out the required DOM elements through specific filtering rules, which begin with ":"
According to different filtering rules, filter selectors can be divided into basic filtering, content filtering, visibility filtering, attribute filtering, sub-element filtering and Form object property filter selectors.

First, basic filter selector


Change the background color of the first DIV element to # BBFFAA
Change the background color of the last div element to # BBFFAA
Change the background color of all DIV elements that are not one class to # BBFFAA
Change the background color of the div element with an even number of index values to # BBFFAA
Change the background color of the div element with an odd index value to # BBFFAA
Change the background color of the div element with index value greater than 3 to # BBFFAA
Change the background color of the div element with index value equal to 3 to # BBFFAA
Change the background color of the div element with an index value of less than 3 to # BBFFAA
Change the background color of all the caption elements to # BBFFAA
Change the background color of all elements that are currently performing the animation to # BBFFAA

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >Second, Content filter Selector

The filtering rules of the Content filter selector are mainly embodied in the child elements and the text content.

Change the background color of the div element containing the text ' di ' to # BBFFAA
Change the background color of a div empty element that does not contain child elements (or text elements) to # BBFFAA
Change the background color of the div element containing the class mini element to # BBFFAA
Change the background color of a DIV element that contains child elements (or text elements) to # BBFFAA

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >Third, Visibility filter selector
The Visibility filter selector selects the appropriate element based on the visible and invisible state of the element

Visible selector: Hidden contains not only elements with the style property display as none, but also elements such as text-hidden fields (<input type= "hidden" >) and Visible:hidden

Change the background color of all visible div elements to # BBFFAA
Select all elements that are not visible, use the show () method in JQuery to display them, and set their background color to # BBFFAA
Select all the text-hidden fields and print their values

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >


Step-by-step learning JQuery (c) Filter selector: Basic Filter Selector && Content Filter Selector && Visibility Filter Selector

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.