Latest web development tutorials

jQuery wrapInner () method

jQuery HTML / CSS Methods jQuery HTML / CSS Methods

Examples

On the contents of each <p> element wrapped <b> element:

$("button").click(function(){
$("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 元素。

可能的值:

  • HTML 元素
  • jQuery 对象
  • DOM 元素
function (index) 可选。规定返回包裹元素的函数。
  • index- 返回集合中元素的 index 位置。


Examples

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.


jQuery HTML / CSS Methods jQuery HTML / CSS Methods