jQuery wrapInner() method
Example
Insert content after each
Wrap the content of the element in a element:
$
(
"
button
"
)
.
click
(
function
(
)
{
$
(
"
p
"
)
.
wrapInner
(
"
"
)
;
}
)
;
Try it »
Definition and Usage
The wrapInner() method wraps all content (innerHTML) inside each selected element with the specified HTML element.
Syntax
$(
selector
).wrapInner(
wrappingElement
,function
(index)
)
| Parameters | Description |
|---|---|
| wrappingElement | Required. Specifies the HTML element to surround the content of each selected element.
Possible values: |
- index - Returns the index position of the element in the set.
More examples
Creating a new element via the DOM
How to use document.createElement() to create an element and wrap the content of each selected element with it.
Wrapping content using a function
Use a function to specify what to wrap the content of each selected element with.
jQuery HTML/CSS methods