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)