Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is .wrapInner() method in jquery ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 133
    Comment on it

    Hello Readers,

    .wrapInner() is the jquery method which is used to wrap the inner HTML element in the set of matched elements.This method wraps the HTML structure by using wrapping element as a parameter and returns the jquery object as a result.

    Syntax :

    $(selector).wrapInner(wrappingElement,function(index))
    

    Parameter :

    wrappingElement : this parameter is required which specifies the HTML element to wrap around the content of each selected element.

    function(index) : this function is optional which specifies a function that returns the wrapping element.

    index : Returns the index position of the element in the set of matched element.

    Code Example :

    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("button").click(function(){
            $("p").wrapInner("<b></b>");
        });
    });
    </script>
    </head>
    <body>
    
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
    
    <button>Wrap button</button>
    
    </body>
    </html>
    

    In the above code we use the wrapInner method and wrap the <p> element to bold <b>.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: