<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").remove();
});
});
</script>
</head>
<body>
<div id="div1" style="height:100px;width:300px;border:1px solid black;background-color:yellow;">
This is div.
<p>This is 2nd div</p>
<p>Thankyou Workingcode.in</p>
</div>
<br>
<button>Remove div and child div</button>
</body>
</html>
The jQuery remove() method removes the selected element(s) and its child elements.
admin Changed status to publish December 26, 2023