The empty method

The empty method removes content from the selected elements (the elements themselves are not removed, but left empty).

Syntax

javascript.empty();

Example

Let's remove the contents of the #test element:

html<p id="test">Hello, <b>world</b>!</p>
javascript$('#test').empty();

HTML the code will look like this:

html<p id="test"></p>

See also

  • method remove,
    which deletes elements without the possibility of their recovery
  • method detach,
    which removes elements with the possibility of their recovery
  • JavaScript method remove,
    which allows you to delete an element