jquery CSS Selector Implementation code (1/2)

Source: Internet
Author: User
Tags xpath

The CSS Tutorial selector includes a wildcard selector, an ID selector, a property selector, a include selector, a class selector, and so on, and their basic format is:

Wildcard selector: $ ("#id *") represents all the elements under that element.

ID Selector: $ ("#id") represents the element that obtains the specified ID.

Property Selector: $ ("Input[type=text]") represents all input elements with the Type property of text.

Include selector: $ ("ul Li a") represents all the a elements in all LI elements under the UL element.

Class Selector: $ (". Class") represents all elements that reference the class style.

Of course, these selectors can be used in conjunction with, say, $ ("#id Input[type=text]"), which means that all input elements with the type attribute under the specified ID element are text. Some subtle changes in jquery are very interesting, such as $ ("ul Li"). AddClass ("Class") and $ ("ul > Li"). AddClass ("class"), they show the effect is different, The first is to be ul under all LI elements to add style, the second is the UL under the first LI element to add style, more specific use of the method can be tested.

The XPath selector (which has not been supported since version 1.3, but is also understood) does not cover much of the content, and their basic format is:

$ ("[@title]") represents the element that selects the attribute with title in all elements.

$ ("[@title ^=t]") means that all property title values are elements that begin with T.

$ ("[@title $=t]") indicates that all property title values are elements that end with T.
$ ("[@title *=t]") indicates that all property title values are elements that contain T.

XPath selectors, like CSS selectors, can work together, can be used with multiple XPath selectors, and can be used in conjunction with CSS selectors, so there are many ways to achieve the requirements you want with the jquery method.

Home 1 2 last page
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.