jQuery wrapInner () method
Examples
On the contents of each <p> element wrapped <b> element:
$("button").click(function(){
$("p").wrapInner("<b></b>");
});
$("p").wrapInner("<b></b>");
});
try it"
Definition and Usage
wrapInner () method using the specified HTML element to wrap each selected element in all content (innerHTML).
grammar
$(selector).wrapInner(wrappingElement,function(index))
参数 | 描述 |
---|---|
wrappingElement | 必需。规定包围在每个被选元素的内容周围的 HTML 元素。 可能的值:
|
function (index) | 可选。规定返回包裹元素的函数。
|
More examples
Create new elements by DOM
How to use document.createElement () to create the element, and use it to wrap each of the contents of the selected element.
Use the function package contents
Use function specify what the contents of each package with the selected element.