How to use HTML WrapAll Method in JQuery

This article describe about HTML WrapAll Method in JQuery.
  • 1688

HTML WrapAll() method in jQuery

  • wrapAll() method wraps determined around the all HTML selected element.

Syntax

This is the simple syntax to use this method:

$(selector).wrapAll(wrappingElement)

  • elem : elem is a DOM element that will be wrapped around the target.

Example

Following is a simple example a simple showing the usage of this method.

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function ()

     {

         $("button").click(function ()

         {

            $("p").wrapAll("<div></div>");

        });

    });

</script>

<style type="text/css">

div{background-color:red;}

</style>

</head>

<body>

<p>This is a JQuery.</p>

<p>This is a .Netheaven.</p>

<button>Wrap all elements</button>

</body>

</html>

Output1

op1.jpg

Output2

op2.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.