.wrapAll()
methodThe .wrapAll()
method in jQuery is used to wrap a new HTML structure around all the matched elements.
.wrapAll()
method Syntax.wrapAll(wrappingElement) .wrapAll(function)
wrappingElement
specifying the structure to wrap around the matched elements.
function
is a callback function returning the HTML content or jQuery object to wrap around all the matched elements.
.wrapAll(wrappingElement)
Create a div element to wrap around all of the paragraph.
HTML
<div class="container"> <p>JavaScript Tutorial</p> <p>Learn jQuery on Lautturi.com</p> </div>
jQuery
$("p").wrapAll("<div class='wrap'></div>");
Result
<div class="container"> <div class="wrap"> <p>JavaScript Tutorial</p> <p>Learn jQuery on Lautturi.com</p> </div> </div>