jQuery | Remove Elements
In jQuery, in order to remove element and content you can use anyone of the following two jQuery methods:
Methods:
- remove() – It is used to remove the selected element (and its child elements).
- empty() – It is used to removes the child elements from the selected element.
Example-1: Using the jQuery remove() Method.
<!DOCTYPE html> <html> <head> <title>jQuery remove() Method</title> <script src= </script> </head> <body> <center> <h1 style="color:green;"> GeeksForGeeks</h1> <h2 id="GFG"> jQuery remove() Method</h2> <br> <button>Click</button> <script> $(document).ready(function() { $("button").click(function() { $("#GFG").remove(); }); }); </script> </center> </body> </html> |
chevron_right
filter_none
Output:
Before Click on the Button:

After Click on the Button:

Example-2: Using the jQuery empty() Method.
<!DOCTYPE html> <html> <head> <title>jQuery empty() Method </title> <script src= </script> </head> <body> <center> <h1 style="color:green;"> GeeksForGeeks</h1> <h2 id="GFG"> jQuery empty() Method </h2> <br> <button>Click</button> <script> $(document).ready(function() { $("button").click(function() { $("#GFG").empty(); }); }); </script> </center> </body> </html> |
chevron_right
filter_none
Output:
Before Click on the Button:
After Click on the Button:

Recommended Posts:
- jQuery | remove()
- How to fadeOut and remove a div using jQuery ?
- How to Add and Remove multiple classes in jQuery ?
- How to remove options from select element using jQuery ?
- jQuery | Add Elements with Examples
- How to remove parent element except its child element using jQuery ?
- jQuery | multiple elements Selector
- PHP | Remove duplicate elements from Array
- How to convert list of elements in an array using jQuery ?
- How to remove the space between inline-block elements?
- Remove all the child elements of a DOM node in JavaScript
- JavaScript | Remove empty elements from an array
- Program to remove empty array elements in PHP
- How to remove table row from table using jQuery ?
- jQuery | jQuery.support Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



