|
.wrapChildren( "Wrapper_Tag_Name", [ Properties ]) - Add a Wrapper for all child element
.wrapChildren() will wrap all the child elements of a parent element and the wrapper will be the new immediate parent for children. It can set attributes to the wrapper using the second parameter.
Parameters
Returns
Example 1
Clicking on "Add Wrapper" button will wrap all the children of the parent div.
JS
HTML
CSS
$.domLoaded(function() {
$.get("#add").on("click", function() {
//add a wrapper to all children of #parent
$.get("#parent").wrapChildren("div", {
"class" : "wrapper",
"text" : "Wrapper and New Parent"
});
});
});
Result
| ||||||||||||||||||||||
