How to Create Remove Element or Content using jQuery

In this article, You will Learn How to Create Remove Element or Content using jQuery

jQuery remove() Method

Example:-

<html>
<head>
<title>jQuery remove()</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/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:red;color:#ffffff">
<p>Welcome to Hub of Tutorials</p>
<p>jQuery remove Method.</p>
</div>
<br>
<button>Remove div element</button>
</body>
</html>

jQuery empty() Method

Example:-

<html>
<head>
<title>jQuery empty()</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("#div1").empty();
  });
});
</script>
</head>
<body>
<div id="div1" style="height:100px;width:300px;border:1px solid black;background-color:red;color:#ffffff">
<p>Welcome to Hub of Tutorials</p>
<p>jQuery remove Method.</p>
</div>
<br>
<button>Empty div element</button>
</body>
</html>

Read on Facebook

Leave A Reply