jquery Content Filter Selector usage analysis

Source: Internet
Author: User

This article mainly introduced the jquery Content Filter selector Usage, the example analysis: Contains (),: Has (),: Empty (),:p arent and so on content filter Selector's use skill, needs the friend to be possible to refer to under

This example describes the jquery content filter selector usage. Share to everyone for your reference. The specific analysis is as follows:

In an HTML document, the content of an element can be text or a child element, and if you use a selector or a content filter selector, you can further filter out the element in the query to a given

Elements of text or child elements

1.: Contains () selector

Lets you select all the elements that contain the given text, in the format:

The code is as follows:

$ ("Selector1:contains (text)")

Such as:

The code is as follows:

$ ("P:contains (' text ')"). CSS ("Background", "#FCF");

2.: Has () selector

Used to filter the elements that contain the given child element, in the format:

The code is as follows:

$ ("Selector1:has (Selector2)")

Selector1 and Selector2 are any valid elements.

Such as:

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, and all empty elements in selector that contain no child elements or text will be included in the query results

Such as:

The code is as follows:

$ ("Td:empty"). CSS ("Background", "#FCF");

4.:p arent Selector

Format:

The code is as follows:

$ ("selector:parent")

Used to select elements that contain child elements or text, as opposed to the empty selector

Such as:

The code is as follows:

$ ("Td:parent"). CSS ("Background", "#FCF");

I hope this article will help you with your jquery programming.

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.