jQuery Tutorial Tutorials - jQuery .wrapInner() method

jQuery .wrapInner() method

The .wrapInner() method in jQuery is used to wrap a new HTML structure around the content of each matched elements.

jQuery .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)

example

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>

Try now

Date:2019-08-25 10:55:20 From:www.Lautturi.com author:Lautturi