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.