1. Use the basic selector of CSS:
A: match all the <a> elements of the link.
# *: Match the element with id *
. *: Matches the element of the CSS class *.
A # * id. * class: matches the id as * id and has a link element with the CSS class as * class.
The above is the style in CSS, Which is wrapped in $ ("") in jQuery, such as jQuery ("p a. Class ")
Take the sub-selector, container selector, and feature selector as an example:
Copy codeThe Code is as follows:
<Ul class = "myList">
<Li> <a href = http://jquery.com> jQuery supports </a>
<Ul>
<Li> <a href = "css1"> CSS1 </a> </li>
<Li> <a href = "css2"> CSS2 </a> </li>
<Li> <a href = "css3"> CSS3 </a> </li>
<Li> Basic XPath </li>
</Ul>
</Li>
<Li>
<Ul>
<Li> Custom selectors </li>
<Li> Form selectors </li>
</Ul>
</Li>
</Ul>
If you want to select all links in the first list <li>, use the sub-selector: ul. myList> li> a instead of ul. myList li a because all these links <a> are the descendant nodes of the <li> element in the list.
Child selector: the parent node and the direct child node are separated by Angle brackets (>.
Feature selector: Pack elements that match specific content. For example, select the link that contains the href value starting with http: //: a [href ^ = http: //]
Input [type = text]: matches all <input> elements whose type attribute is text.
Div [title = ^ my]: matches all <div> elements whose title property value starts with "my.
Select by location
A: first: The selector matches the first <a> element on the page.
P: odd, p: even match odd and even elements respectively.
I will not give you an example of others. If necessary, you can find them on the relevant website.