jQuery in Action
Summary
47
wrapped set is popped from the stack, leaving the previous wrapped set exposed
for subsequent commands to operate upon.
for subsequent commands to operate upon.
Another handy jQuery method that modifies the wrapped set stack is
and-
Self()
, which merges the two topmost sets on the stack into a single wrapped set.
2.4 Summary
This chapter focused on creating and adjusting sets of elements (referred in this
chapter and beyond as the wrapped set) via the many methods that jQuery pro-
vides for identifying elements on an
chapter and beyond as the wrapped set) via the many methods that jQuery pro-
vides for identifying elements on an
HTML
page.
jQuery provides a versatile and powerful set of selectors, patterned after the
selectors of
CSS
, for identifying elements within a page document in a concise but
powerful syntax. These selectors include not only the
CSS2
syntax currently sup-
ported by most browsers, but also
CSS3
syntax; a handful of custom selectors;
and, with a plugin, even some basic
XP
ath selectors.
jQuery also allows us to create or augment a wrapped set using
HTML
frag-
ments to create new elements on the fly. These orphaned elements can be manip-
ulated, along with any other elements in the wrapped set, and eventually
attached to parts of the page document.
ulated, along with any other elements in the wrapped set, and eventually
attached to parts of the page document.
jQuery provides a robust set of methods to adjust the wrapped set to hone the
contents of the set, either immediately after creation or midway through a set of
chained commands. Applying filtering criteria to an already existing set can also
easily create new wrapped sets.
chained commands. Applying filtering criteria to an already existing set can also
easily create new wrapped sets.
All in all, jQuery gives us a lot of tools to make sure that we can easily and accu-
rately identify the page elements that we wish to manipulate.
In this chapter, we covered a lot of ground without doing anything to the
DOM
elements of the page. But now that we know how to select the elements that we
want to operate upon, we're ready to start adding life to our pages with the power
of the jQuery commands.
want to operate upon, we're ready to start adding life to our pages with the power
of the jQuery commands.
Command syntax: andSelf
andSelf()
Merges the two previous wrapped sets in a command chain
Parameters
none
Returns
The merged wrapped set
The merged wrapped set