Latest web development tutorials

jQuery remove () method

jQuery HTML / CSS Methods jQuery HTML / CSS Methods

Examples

Remove all the <p> element:

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

try it"

Definition and Usage

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

This method also removes the selected element data and events.

Tip: To remove the element, but keep the data and events, use the detach () method instead.

Tip: If you need to remove content from the selected element, use empty () method.


grammar

$(selector).remove()


Examples

More examples

Different detach () and remove () between
Between different methods of presentation detach () and remove ().


jQuery HTML / CSS Methods jQuery HTML / CSS Methods