JQuery learning 2 selector instructions

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.