-
Book Overview & Buying
-
Table Of Contents
jQuery 1.4 Reference Guide
By :
Each jQuery object we create contains a number of properties alongside its methods. These properties allow us to inspect various attributes of the object.
The number of DOM elements matched by the jQuery object.
Suppose we had a simple unordered list on the page:
<ul> <li>foo</li> <li>bar</li> </ul>
We can determine the number of list items by examining .length.
$.print('Length: ' + $('li').length);This will output the count of items:
Length: 2
The selector string that was used to create the jQuery object.
The .live() method for binding event handlers uses this property to determine how to perform its searches. Plug-ins that perform similar tasks may also find the property useful.
This property contains a string representing the matched set of elements. However, if DOM traversal methods have been called on the object, the string may not be a valid jQuery selector expression. For example, examine the value of...
Change the font size
Change margin width
Change background colour