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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 241
    Comment on it

    Hello Readers,

    unwrap() is the jquery method which is used to removes the element of the parent of the selected or matched element in jquery and after that it returns the jquery object as a result.

    Syntax :

    $(selector).unwrap()
    

    In the above syntax unwrap() method not use any parameter

    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").unwrap();
        });
    });
    </script>
    <style>
    div{background-color: yellow;}
    article{background-color: pink;}
    </style>
    </head>
    <body>
    
    <div>
      <p>This is a paragraph inside a div element.</p>
    </div>
    
    <article>
      <p>This is a paragraph inside an article element.</p>
    </article>
    
    <button>unwrap button</button>
    
    </body>
    </html>
    

    In the above code we use the unwrap() method and use the <p> tag as a selector and unwrap or remove the parent elements of each <p> element in jquery.

 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: