jquery Hierarchy Selector

Source: Internet
Author: User

Basic Selector

$ (' #id ')--match all #id

$ (' P ')--match all P tags

$ ('. class ')--match all. Class

$ (' * ')--$ (' #id * ') matches all child nodes under #id

$ (' #id,. class ')--matches all #id and. Class

Hierarchy Selector

Parent-Child Hierarchy

$ (' #parent. Span1 ')--match all the class attributes in the parent child node to Span1 (match span1 in all derived subnodes)

$ (' #parent > P ')--matches all P tags in the parent node (only the P of the Son node, the p of the grandson node will not be matched)

Sibling level

$ (' Pre + Next ')--match next to the pre (no node next to the pre will be matched to)

$ (' Pre ~ next ')--match all next to the pre (as long as the next on the pre will be matched)

Filter selector (no spaces before and after a colon)

Simple filtering

$ (' Li:first ')--match the first Li tag

$ (' li:last ')--match last Li Tag

$ (' #id p:not (#np) ')--match #id All ID is not NP p label

$ (' li:odd ')--an odd number of Li (index starting from 0)

$ (' Li:even ')--an even number of Li (index starting from 0)

$ (' li:eq (0) ')--No. 0 Li (Index starting from 0)

$ (' li:gt (0) ')--No. 0 + 1 li (Index starting from 0)

$ (' li:lt (1) ')--第1-1个 Li (Index starting from 0)

$ ('. H:header ')--match all. h title tags, for example (H1,H2 ... )

Content filtering

$ (' Div:contains (' contains ') ')--will match all content containing contains div, and multiple div nesting will also match to the outer div

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.