JQuery content filter selector Usage Analysis _ jquery-js tutorial

Source: Internet
Author: User
This article mainly introduces the usage of the jQuery content filter selector. examples show how to use the content filter selector, such as contains (), has (), empty (), and parent, for more information about jQuery content filtering selector, see the following example. Share it with you for your reference. The specific analysis is as follows:

In an HTML document, the content of an element can be text or child elements. If you use a selector or content filter selector together, you can further filter the elements that have been queried to generate a given

Elements of text or child elements

1.: contains () Selector

Used to select all elements that contain the given text. format:

The Code is as follows:

$ ("Selector1: contains (text )")

For example:

The Code is as follows:

$ ("P: contains ('text')" ).css ("background", "# FCF ");

2.: has () Selector

Used to filter the elements that are contained in the subelement. format:

The Code is as follows:

$ ("Selector1: has (selector2 )")

Selector1 and selector2 are any valid elements.

For example:

The Code is as follows:

$ ("Li: has (p)" ).css ("background", "red ");

3.: empty () Selector

Format:

The Code is as follows:

$ ("Selector: empty ")

Used to select all elements that do not contain child elements or text. All null elements in selector that do not contain child elements or text will be included in the query results.

For example:

The Code is as follows:

$ ("Td: empty" ).css ("background", "# FCF ");

4.: parent Selector

Format:

The Code is as follows:

$ ("Selector: parent ")

Used to select an element that contains child elements or text, which is opposite to the empty selector.

For example:

The Code is as follows:

$ ("Td: parent" ).css ("background", "# FCF ");

I hope this article will help you with jQuery programming.

Related Article

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.