Easy Tutorial
❮ Jquery Traversing Filtering Event Delegatetarget ❯

jQuery - Remove Elements


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


Remove Elements/Content

To remove elements and content, you can generally use the following two jQuery methods:


jQuery remove() Method

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

Example

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

jQuery empty() Method

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

Example

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

Filtering Removed Elements

The jQuery remove() method can also accept a parameter that allows 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");
❮ Jquery Traversing Filtering Event Delegatetarget ❯