jQuery remove()Method

jQuery HTML/CSS 方法jQuery HTML/CSS Methods

Examples

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 the selected element's data and events.

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

Tip:If you only need to remove content from the selected elements, use theempty()method.


Syntax

$(selector).remove()


实例

More Examples

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


jQuery HTML/CSS 方法jQuery HTML/CSS Methods

Other Extensions