Easy Tutorial
❮ Traversing Parentsuntil Jq Event Currenttarget ❯

jQuery empty() Method

jQuery HTML/CSS Methods

Example

Remove the content of all <div> elements:

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

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 keep its data and events, use the detach() method.

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


Syntax


jQuery HTML/CSS Methods

❮ Traversing Parentsuntil Jq Event Currenttarget ❯