English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery empty() Method

jQuery HTML/CSS Methods

The empty() method removes all child nodes (including text nodes) from the selected element.

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

To remove an element without removing its data and events (so that they can be re-added later), usedetach()Method.

To remove an element and its data and events, useremove()Method.

Syntax:

$ (selector).empty()

Example

Remove all child nodes (including text nodes) from all paragraphs:

$("button").click(function() {
  $("p").empty();
});
Test and See‹/›

jQuery HTML/CSS Methods