jQuery remove() Method

jQuery HTML/CSS Methods jQuery HTML/CSS Methods

Example

Remove all <p> elements:

$("button").click(function(){
  $("p").remove();
});

Try it yourself »

Definition and Usage

The remove() method removes the selected elements, including all text and child nodes.

This method also removes data and events of the selected elements.

Tip: To remove the elements without removing data and events, use the detach() method instead.

Tip: To remove only the content from the selected elements, use the empty() method.


Syntax

$(selector).remove()

Examples

Try it Yourself - Examples

Difference between detach() and remove()
Show the difference between the detach() and remove() methods.


jQuery HTML/CSS Methods jQuery HTML/CSS Methods


SHARE THIS PAGE

COLOR PICKER

colorpicker