How to use HTML WrapInner Method in JQuery

This article describe about HTML WrapInner Method in JQuery.
  • 1965

HTML WrapInner() method in jQuery

  • wrapInner() method wraps specified HTML element or the inner child contents around the content of each HTML selected element with a DOM element.

Syntax

$(selector).wrapInner(wrappingElement)

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").wrapInner("<b></b>");

        });

    });

</script>

</head>

<body>

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

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

<button>Wrap a b element</button>

</body>

</html>

Output1

op1.jpg

Output2

op2.jpg

Using a Function

wrapInner() method using a function to determine what to wrap around the content of each HTML selected element.

Syntax

$(selector).wrapInner(function())

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

© 2019 DotNetHeaven. All rights reserved.