-
Book Overview & Buying
-
Table Of Contents
jQuery 1.4 Reference Guide
The CSS specification also allows elements to be identified by their attributes. While not widely supported by browsers for the purpose of styling documents, these attribute selectors are highly useful and jQuery allows us to employ them regardless of the browser being used.
When using any of the following attribute selectors, we should account for attributes that have multiple, space-separated values. As these selectors see attribute values as a single string, $('a[rel=nofollow]'); for example, will select <a rel="nofollow" href="example.html">Some text</a> but not <a rel="nofollow self" href="example.html">Some text</a>.
Attribute values in selector expressions can be written as bare words or surrounded by quotation marks. Therefore, the following variations are equally correct:
Bare words: $('a[rel=nofollow self]')
Double quotes inside single quotes: $('a[rel="nofollow self"]')
Single quotes inside double quotes: $("a[rel='nofollow self']")
Escaped...
Change the font size
Change margin width
Change background colour