jQuery in Action

76
CHAPTER 3
Bringing pages to life with jQuery
Sometimes we may not want to wrap the elements that are in a matched set, but
rather their contents. For just such cases, the
wrapInner()
method is available:
Now that we know how to create, wrap, copy, and move elements, we may wonder
how we make them go away.
3.3.4 Removing elements
If we want to empty or remove a set of elements, this can be accomplished with
the
remove()
command whose syntax is as follows:
Note that, as with many other jQuery commands, the wrapped set is returned as
the result of this command. The elements that were removed from the
DOM
are
still referenced by this set (and hence not yet eligible for garbage collection) and
can be further operated upon using other jQuery commands including
appendTo()
,
prependTo()
,
insertBefore()
,
insertAfter()
, and any other similar behaviors
we'd like.
Command syntax: wrapInner
wrapInner(wrapper)
Wraps the contents, to include text nodes , elements of the matched set with the passed
HTML tags or a clone of the passed element.
Parameters
wrapper
(String|Element) The opening and closing tags of the element with which to
wrap each element of the matched set, or an element to be cloned and server
as the wrapper.
Returns
The wrapped set
Command syntax: remove
remove()
Removes all elements in the wrapped set from the page DOM
Parameters
none
Returns
The wrapped set


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.