What is the difference between jQuery.empty() and jQuery.remove() methods in jQuery?

jQuery.empty()

The empty() method removes all child nodes from the set of matched elements.

Example

You can try to run the following code to learn how to work with jQuery empty() method:


   
      jQuery empty() method
      
       
      
     
      
   
   
   
   
      

Click on any square below to see the result:

             
ONE
     
TWO
     
THREE
           

jQuery.remove()

The remove(expr) method removes all matched elements from the DOM. This does not remove them from the jQuery object, allowing you to use the matched elements further.

Here is the description of all the parameters used by this method ?

  • expr ? This is an optional jQuery expression to filter the set of elements to be removed.

Example

You can try to run the following code to learn how to work with jQuery remove() method. Here, the div is removed and appended using remove() and appendTo() method respectively:


   
      jQuery remove() method
      
       
      
       
      
   
   
   
   
      

Click on any square below to see the result:

     

THIS IS TEST

     
             
ONE
     
TWO
     
THREE
           
Updated on: 2026-03-11T23:14:17+05:30

367 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements