jQuery remove()

jQuery remove() method is used to remove existing HTML elements from DOM.

To remove existing HTML elements using jQuery,

  1. Select HTML elements to be removed using jQuery selectors.
  2. Call remove() method on the selected HTML elements to remove them from DOM.

In this tutorial, you will learn about jQuery remove() method, its syntax and usage, with examples.

Syntax – jQuery remove()

To remove the HTML element permanently from DOM using jQuery, use remove() method on the selection. Following is the syntax of jQuery remove() method :

$("htmlElement").remove();
ADVERTISEMENT

Examples – jQuery remove()

The following examples help you understand the usage of jQuery remove() method.

1. Example – Remove HTML elements based on class

In the following example, on clicking a button, using jQuery remove() method, we remove HTML elements whose class is abc.

2. Example – Remove div elements based on ID

Following example demonstrates how to remove selected DIV elements based on id.

Conclusion

In this jQuery Tutorial, we have learnt jQuery remove() method : Syntax and Usage with examples.