jQuery wrap () method
Examples
Wrap each <p> element in the <div> element:
$("button").click(function(){
$("p").wrap("<div></div>");
});
$("p").wrap("<div></div>");
});
try it"
Definition and Usage
wrap () method using the specified HTML element to wrap each selected element.
grammar
$(selector).wrap(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 selected element.
Use the function element package
Use what function requires that each package selected elements.
Parcels and unlock elements
How to unlock the elements between packages and task switching.