WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

jQuery - Remove Elements


With jQuery, you can easily delete existing HTML elements.


Remove element /content

To delete elements and content, generally use the following two jQuery methods:

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

jQuery remove() method

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

Example

$("#div1").remove();
Try it Yourself »

jQuery empty () method

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

Example

$("#div1").empty();
Try it Yourself »

Filter deleted elements

jQuery remove () method also accepts a parameter that allows you to filter the deleted elements.

This parameter can be the syntax of any jQuery selector.

The following example deletes all class = "italic" <p> element:

Example

$("p").remove(".italic");
Try it Yourself »