This article mainly introduces the contains selector usage in jQuery and analyzes the functions, definitions, and usage skills of the contains selector in the form of examples. It has some reference value, for more information about how to use the contains selector in jQuery, see the following example. Share it with you for your reference. The specific analysis is as follows:
This selector matches the elements that contain the given text.
Syntax:
The Code is as follows:
$ (": Contains (text )")
This selector should also be used with other selectors, such as class selector and element selector. For example:
The Code is as follows:
$ ("Li: contains ('html')" ).css ("color", "blue ")
The above Code sets the font color in the li element containing "html" to blue.
If it is not used with other selectors, the default state is used with the * selector. For example, $ (": contains") is equivalent to $ ("*: contains ").
Parameter List:
Parameters |
Description |
Text |
A string to be searched. |
Instance code:
Instance 1:
The Code is as follows:
Foot home