Insertion and Deletion Methods
The methods described here insert, delete, and replace document
content. In the method signatures below, the
content
argument may be a jQuery object, a string
of HTML, or an individual document element, and the
target
argument may be a jQuery object, an
individual document element, or a selector string. See Getting and Setting Element Content and Chapter 3 for further details.
after(
content
)after(
f
(idx
):content)Insert
content
after each selected element, or invokef
as a method ofâand insert its return value afterâeach selected element.append(
content
)append(
f
(idx
,html
):content)Append
content
to each selected element, or invokef
as a method ofâand append its return value toâeach selected element.appendTo(
target
):jQueryAppends the selected elements to the end of each specified
target
element, cloning them as necessary if there is more than one target.before(
content
)before(
f
(idx
):content)Like
after()
, but make insertions before the selected elements.clone([
data
=false]):jQueryMakes a deep copy of each of the selected elements and returns a new jQuery object representing the cloned elements. If
data
istrue
, also clones the data (including event handlers) associated with the selected elements.detach([
sel
])Like
remove()
, but does not delete any data associated with the detached elements.empty()
Deletes the content of all selected elements.
html():string
html(
htmlText
)html(
f
(idx
,current
):htmlText)With no arguments, return the content of the first selected ...
Get jQuery Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.