Loading Please Wait...

Logo Lynxsia IT Solutions

jQuery DOM Remove

JQ DOM Remove

With jQuery, it is easy to remove existing HTML elements.

Remove Elements/Content

To remove elements and content, there are mainly two jQuery methods:

  • remove() - Removes the selected element (and its child elements)
  • empty() - Removes the child elements from the selected element
jQuery remove() Method

The jQuery remove() method removes the selected element(s) and its child elements.

					 
        
          $("#div1").remove();
        
      
jQuery empty() Method

The jQuery empty() method removes the child elements of the selected element(s).

					 
        
          $("#div1").empty();
        
      
Filter the Elements to be Removed

The jQuery remove() method also accepts one parameter, which allows you to filter the elements to be removed.

The parameter can be any of the jQuery selector syntaxes.

The following example removes all <p> elements with class="test".

					 
        
          $("p").remove(".test");
        
      

This example removes all <p> elements with class="test" and class="demo":

					 
        
          $("p").remove(".test, .demo");
        
      

How you feel about this blog:

Share this blog on:

Report Us

If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com

Contact Us
Ads
Logo
Lynxsia IT Solutions

We are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..

Kotwali Road, Chhiptehri, Banda, 210001, UP, India

Copyright © 2022, Lynxsia IT Solutions, All rights reserved