jQuery empty()Method

jQuery HTML/CSS 方法jQuery HTML/CSS Methods

Examples

Remove the content of all <div> elements:

$("button").click(function(){ $("div").empty(); });

Try it yourself »

Definition and Usage

The empty() method removes all child nodes and content from the selected elements.

Note:This method does not remove the element itself, or its attributes.

Tip:To remove the element, but retain data and events, use thedetach()method.

Tip:To remove the element and its data and events, use theremove()method.


Syntax

$(selector).empty()


jQuery HTML/CSS 方法jQuery HTML/CSS Methods

Other Extensions