Copy Code code as follows:
<style type= "Text/css" >
/* Highlighting * *
. highlight{
Background-color:gray
}
</style>
Copy Code code as follows:
<body>
<div>
<p>Hello</p>
</div>
<div id= "test" >id as Test div</div>
<input type= "checkbox" id= "S1" name= "Football" value= "football"/> Football
<input type= "checkbox" name= "Volleyball" value= "Volleyball"/> Volleyball
<input type= "checkbox" id= "S3" Name= "basketball" value= "basketball"/> Basketball
<input type= "checkbox" id= "S4" Name= "other" value= "others"/> Other
</body>
1. [Attribute] Usage
Definition: Matches the element that contains the given property
Copy Code code as follows:
$ ("Div[id]"). AddClass ("highlight"); Find all DIV elements that contain ID attributes
2. [Attribute=value] Usage
Definition: Matches the given property is an element of a particular value
Copy Code code as follows:
$ ("Input[name= ' basketball ']"). attr ("Checked", true); The Name property value is basketball INPUT element selected
3. [Attribute!=value] Usage
Definition: Matching a given property is an element that does not contain a specific value
Copy Code code as follows:
$ ("input[name!= ' basketball ']"). attr ("Checked", true); The Name property value is not selected for basketball INPUT element
This selector is equivalent to: not ([Attr=value]) to match elements that contain specific attributes but not equal to a particular value, use [Attr]:not ([Attr=value])
$ ("Input:not (input[name= ' basketball ')"). attr ("Checked", true);
4. [Attribute^=value] Usage
Definition: Matches a given property as an element starting with some value
Copy Code code as follows:
$ ("input[name^= ' foot ']"). attr ("Checked", true); Find all input elements with ' foot ' started in name
5. [Attribute$=value] Usage
Definition: Matches the given property is an element that ends with some value
Copy Code code as follows:
$ ("input[name$= ' Ball ']"). attr ("Checked", true); Find all input elements with name ending with ' ball '
6. [Attribute*=value] Usage
Definition: Matches a given property to an element that contains certain values
Copy Code code as follows:
$ ("input[name*= ' sket ']"). attr ("Checked", true); Find all input elements with ' sket ' in name
7. [Selector1][selector2][selectorn] Usage
Definition: Composite property selector, which needs to be satisfied with multiple conditions
Copy Code code as follows:
$ ("input[id][name$= ' Ball ']"). attr ("Checked", true); All of the ID attributes are found, and its Name property ends with Ball