In this article we will learn how to use wrap() method in jQuery with example.


jQuery wrap() method is used to wrap specified HTML elements around each selected element. The wrap() function can accept any string or object that could be passed through the $() factory function.

Let’s see, Example of jQuery warp() method:

 <!DOCTYPE html>
<html xmlns="">
    <title>Example of jQuery wrap method</title>
    <script type="text/javascript" src=""></script>
        $(document).ready(function () {
            $("button").click(function () {
                var content = '<div class="div"></div>';
        .div {
            margin: 5px;
            padding: 2px;
            border: 2px solid #666;
            width: 60px;
    <button>Click on any square to wrap the text:</button><br />
    <div class="div" id="destination">We are going to wrap this text</div>

 Let's check live example

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like