Category: Attribute
Category: Attribute
The CSS specification allows elements to be identified by their attributes. While not supported by some older browsers for the purpose of styling documents, jQuery allows you to employ them regardless of the browser being used.
When using any of the following attribute selectors, you should account for attributes that have multiple, space-separated values. Since these selectors see attribute values as a single string, this selector, for example, $("a[rel='nofollow']")
, will select <a href="jquery-category-selectors-example-html.html?lang=en" rel="nofollow">Some text</a>
but not <a href="jquery-category-selectors-example-html.html?lang=en" rel="nofollow foe">Some text</a>
.
Attribute values in selector expressions must follow the rules for W3C CSS selectors; in general, that means anything other than a 登录查看完整内容