Latest web development tutorials

jQuery empty () method

jQuery HTML / CSS Methods jQuery HTML / CSS Methods

Examples

Remove the contents of all <div> element:

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

try it"

Definition and Usage

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

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

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

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


grammar

$(selector).empty()


jQuery HTML / CSS Methods jQuery HTML / CSS Methods