JQuery (3) filter selector: Basic filter selector & amp; Content Filter selector & amp; visibility filter selector, jquery Selector

Source: Internet
Author: User

JQuery (3) filter selector: Basic filter selector & content filter selector & visibility filter selector, jquery Selector

Filter selector:

The filter selector mainly filters out the required DOM elements based on specific filter rules. All the selectors start ":".
Based on different filtering rules, the filter selector can be divided into basic filtering, content filtering, visibility filtering, attribute filtering, subelement filtering, and form object attribute filtering selector.

I. 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 whose class is not one to # bbffaa
Change the background color of the div element whose index value is an even number to # bbffaa
Change the background color of div elements whose index value is odd to # bbffaa
Change the background color of the div element whose index value is greater than 3 to # bbffaa
Change the background color of the div element whose index value is 3 to # bbffaa
Change the background color of the div element whose index value is less than 3 to # bbffaa
Change the background color of all title elements to # bbffaa
Change the background color of all elements currently being animated to # bbffaa

<! Doctype html public "-// W3C // dtd html 4.01 // EN" "http://www.w3.org/TR/html4/strict.dtd"> Ii. Content Filtering Selector

The filtering rules of the content filtering selector are mainly reflected in the child elements and text content contained in the selector.

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 containing child elements (or text elements) to # bbffaa

<! Doctype html public "-// W3C // dtd html 4.01 // EN" "http://www.w3.org/TR/html4/strict.dtd"> 
3. Visibility filter Selector

The visibility filter selector selects the corresponding elements based on the visible and invisible states of the elements.

Visible selector: hidden contains not only the elements whose style attribute display is none, but also elements such as <input type = "hidden"> and visible: hidden.

Change the background color of all visible div elements to # bbffaa
Select all invisible elements, use the show () method in jQuery to display them, and set the background color to # bbffaa.
Select all text hiding fields and print their values.

<! Doctype html public "-// W3C // dtd html 4.01 // EN" "http://www.w3.org/TR/html4/strict.dtd"> 


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.