English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The wrapAll() method wraps the specified HTML element around all selected elements.
$.wrapAll(wrappingElement)
Wrap the DIV element around all <p> elements:
$("button").click(function(){ $("p").wrapAll("<div></div>"); });Test and See‹/›
This example uses document.createElement() to create a DIV element and wrap it around all <p> elements:
$("button").click(function(){ $("p").wrapAll(document.createElement("div")); });Test and See‹/›
Note that in this example, all the content between paragraphs is forgotten, for example (About me?):
This is the first paragraph.
This is the second paragraph.
This is the last paragraph.
The difference between the wrap() method and the wrapAll() method:
$("#btn1").click(function(){ $("p").wrap("<div></div>"); }); $("#btn2").click(function(){ $("p").wrapAll("<div></div>"); });Test and See‹/›
Parameter | Description |
---|---|
wrappingElement | Specify the structure to wrap all selected elements Possible Values:
|