Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
THE WORLD'S LARGEST WEB DEVELOPER SITE

jQuery empty() Method

❮ jQuery HTML/CSS Methods

Example

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 elements without removing data and events, use the detach() method.

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


Syntax

$(selector).empty()

❮ jQuery HTML/CSS Methods