jQuery in Action
32
CHAPTER 2
Creating the wrapped element set
snippet into the page's ready handler) right after the element containing text Div 2
(which has the
(which has the
id
of
someParentDiv
). The lower portion of the figure shows that the
defined event handler is triggered when the first newly-created
<div>
is clicked.
Don't be too worried that we haven't covered much of what you may need to
fully understand the previous example; we'll get to all of it soon enough. In fact,
let's get right to manipulating the wrapped set, including the
let's get right to manipulating the wrapped set, including the
filter()
command
we used in the example.
2.3 Managing the wrapped element set
Once we've got the set of wrapped elements that we either identified by using a
selector to match existing
selector to match existing
DOM
elements or created as new elements using
HTML
snippets (or a combination of both), we're ready to manipulate those elements
using the powerful set of jQuery commands. We'll start looking at those com-
mands in the next chapter; but what if we're not quite ready yet? What if we want
to further refine the set of elements wrapped by the jQuery function?
using the powerful set of jQuery commands. We'll start looking at those com-
mands in the next chapter; but what if we're not quite ready yet? What if we want
to further refine the set of elements wrapped by the jQuery function?
In this section, we'll explore the many ways that we can refine, extend, or sub-
set the set of wrapped elements that we wish to operate upon.
Figure 2.5 New HTML elements can be created under script control and given
advanced attributes, such as event handlers, all in a single jQuery statement.
advanced attributes, such as event handlers, all in a single jQuery statement.