jQuery - Remove Elements


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


Remove Elements/Content

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

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

jQuery remove() Method

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

Example

$("#div1").remove();

Try it Yourself »


jQuery empty() Method

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

Example

$("#div1").empty();

Try it Yourself »


Filter the Elements to be Removed

The jQuery remove() method also accepts a parameter, allowing you to filter the elements to be removed.

This parameter can be any jQuery selector syntax.

The following example removes all <p> elements with class="italic":

Example

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

Try it Yourself »
Other Extensions