Attribute selector, jquery attribute Selector

Source: Internet
Author: User

Attribute selector, jquery attribute Selector

The attribute selector can select an element based on its attributes and attribute values.
In CSS3, three attribute selectors are added to enable the attribute selector to have the concept of wildcards.

  • [Attr * = val] attribute Selector
    If an element uses attr to represent an attribute and its attribute value contains the character specified by val, the element uses this style.
[Id * = "sh"] {font-family: "MS Serif", "New York", serif; color: #76ee00 ;...}

The above code snippet indicates that the HTML5 element id attribute contains the "sh" character. This style can be used.

  • [Attr ^ = val] attribute Selector
    If the attribute value starts with a character specified by val, this style is used for this element. For the preceding example, you can change the attribute selector to "[id ^ = shm]".
  • [Attr $ = val] attribute Selector

    The attribute value ends with the character specified by val. This style is used for this element. You can change the attribute selector to "[id $ = shm]".

The attribute selector is also called a restriction selector. It defines the element style based on the specified attribute as a restriction. In addition to the three types mentioned above, there are also four types of selectors: attribute matching, exact attribute matching, blank allocation matching, and character-to-character matching.

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.