English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The wrapInner() method wraps the specified HTML element around the content of each selected element.
Wrap an element around the content:
$(selector).wrapInner(wrappingElement)
Wrap an element around the content using a function:
$(selector).wrapInner(function(index))
Wrap the <b>element around the content of each <p>element:
$("button").click(function(){ $("p").wrapInner("<b></b>"); });Test See‹/›
This example uses document.createElement() to create a <b> element and wrap it around the content of each <p> element:
$("button").click(function(){ $("p").wrapInner(document.createElement("b")); });Test See‹/›
Use a function to wrap content:
$("button").click(function(){ $("p").wrapInner(function(){ return document.createElement("b"); }); });Test See‹/›
Parameters | Description |
---|---|
wrappingElement | Specify the HTML element that wraps around the content of each selected element. Possible Values:
|
function(index) | Specify a function that returns the wrapping element
|