Latest web development tutorials

jQuery wrapAll () method

jQuery HTML / CSS Methods jQuery HTML / CSS Methods

Examples

All wrapped in <p> elements in the <div> element:

$("button").click(function(){
$("p").wrapAll("<div></div>");
});

try it"

Definition and Usage

wrapAll () method using the specified HTML element to wrap all selected elements.


grammar

$(selector).wrapAll(wrappingElement)

参数 描述
wrappingElement 必需。规定包裹被选元素的 HTML 元素。

可能的值:

  • HTML 元素
  • jQuery 对象
  • DOM 元素


Examples

More examples

Create new elements by DOM
How to use document.createElement () to create the element, and use it to wrap all selected elements.


jQuery HTML / CSS Methods jQuery HTML / CSS Methods