The example in this article describes the [Attribute*=value] selector usage in jquery. Share to everyone for your reference. The specific analysis is as follows:
This selector can match the element for which the given property contains some values.
Syntax structure:
Copy Code code as follows:
Parameter list:
Parameters |
Describe |
Attribute |
Defines the properties to find. |
Value |
Defines the value to find. Quotation marks are optional in most cases. However, you avoid conflicts when you encounter such things as property values containing "]". |
Instance code:
Example one:
Copy Code code as follows:
<! DOCTYPE html>
<meta charset= "Utf-8" >
<meta name= "Author" co ntent= "http://www.jb51.net/"/>
<title> Cloud Communities </title>
<script type= "Text/javascript" src= " Mytest/jquery/jquery-1.8.3.js "></script>
<script type=" Text/javascript ">
$ (document). Ready (function () {
$ ("button"). Click (function () {
$ ("li[id*= ' ir ']"). CSS ("Color", "blue") ;
})
})
</script>
<body>
<ul>
<li id= "a" >ht ML zone </li>
<li id= "second" >jquery zone </li>
</ul>
<ul>
Li id= "third" > Welcome to Yun-Habitat community </li>
<li> cloud-Habitat Community welcome you </li>
</ul>
<button> Click See Effects </button>
</body>
The above code sets the text color to blue in the LI element, with an LI element with "IR" in the id attribute value.
Example two:
Copy Code code as follows:
<! DOCTYPE html>
<meta charset= "Utf-8" >
<meta name= "Author" co ntent= "http://www.jb51.net/"/>
<title> Cloud Communities </title>
<script type= "Text/javascript" src= " Mytest/jquery/jquery-1.8.3.js "></script>
<script type=" Text/javascript ">
$ (document). Ready (function () {
$ ("button"). Click (function () {
$ ("Li[id*=[ir]"). CSS ("Color", "blue");
})
})
</script>
<body>
<ul>
<li id= "F[irst" >h tml Zone </li>
<li id= "second" >jquery zone </li>
</ul>
<ul>
&L T;li id= "Third" > Welcome to Yun-Habitat community </li>
<li> cloud-Habitat Community welcome you </li>
</ul>
<button> Click View effects </button>
</body>
From the above code you can see how the code contains "[" or "]", you must enclose quotes, or you will cause a matching error.
I hope this article will help you with your jquery programming.