-
Book Overview & Buying
-
Table Of Contents
jQuery 1.4 Reference Guide
These methods help us to work with the DOM elements underlying each jQuery object.
Return the number of DOM elements matched by the jQuery object.
.size()
The number of elements matched.
Suppose we had a simple unordered list on the page:
<ul> <li>foo</li> <li>bar</li> </ul>
We could determine the number of list items by calling .size().
$.print('Size: ' + $('li').size());This would output the count of items:
Size: 2
The .length property, discussed in Chapter 9, jQuery Properties, is a slightly faster way to get this information.
Retrieve the DOM elements matched by the jQuery object.
.get([index])
index (optional): An integer indicating which element to retrieve
A DOM element or an array of DOM elements if the index is omitted.
The .get() method grants us access to the DOM nodes underlying each jQuery object. Suppose we had a simple unordered list on the...
Change the font size
Change margin width
Change background colour