JQuery Selector Detailed introduction and finishing _jquery

Source: Internet
Author: User

JQuery Selector

CSS selector,

Such as:

$ (' #title1 > Li ') is all the list items (LI) in the child element (>) that has the ID title1 (#title).

$ (' #title1 li:not (. Class1) ') is all list items that have no (not) Class1 class in the descendant element that has the ID title.

The jquery library supports XPath selectors.

Such as:

$ (' a[@title] ') to get all the links with the title attribute. You can also use the @ symbol.

Such as:

$ (' div[ol] ') is a DIV element that contains an OL attribute for acquisition. Of course, the ^ (start) $ (ending) * (arbitrary) in a regular expression is also allowed.

Examples are as follows:

$ (' a[href^= ' mailto: '] ' to get links to all emails.

$ (' a[href$= '. rar '] ') to obtain all links to rar files.

$ (' a[href*= ' tao028.com "]") to get all the links that contain tao028.com. Custom selector,

Such as:

$ (' Div:eq (1) ') to get the 2nd item in the DIV element collection, note that it is a single object with length 1.

$ (' Div:nth-child (1) ') to get all the first div in the set of DIV elements, note that it is a collection of objects, and then elaborate later.

$ (' tr:odd ') for obtaining all odd rows.

$ (' Tr:even ') to obtain all even rows.

$ (' Td:contains (' hahaha ') ') is the element that gets all the cells to contain hahaha.

Thank you for reading, I hope to help you, thank you for your support for this site!

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.