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