Home >>jQuery Tutorial >jQuery remove() Method

jQuery remove() Method

jQuery remove() Method

jQuery remove() method in jQuery is used to removes the selected elements, including all child nodes and text and also removes events and data of the selected elements.

Syntax:
$(selector).remove(selector)

Parameter Values

Parameter Description
selector It is optional parameter and is used to specifies one or more elements to be removed. For separate elements Use comma (,) to remove multiple elements
Here is an Example of jQuery remove() Method:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".btn1").click(function(){
$(".txt").remove();
});
});
</script>
</head>
<body>
<p class="txt">This is First paragraph.</p>
<p class="txt">This is Second paragraph.</p>
<button class="btn1">Click me to Remove p elements</button>
</body>
</html>

Output:

This is First paragraph.

This is Second paragraph.