What is the empty() method in jQuery?

In jQuery, the empty() method is used to remove all the child elements of the selected element in the jQuery collection.

Syntax


(a).empty()

  • a is the element from which we will remove all child elements.

Code

In the code below, the content of the span elements are all removed once the Remove button is clicked.

Free Resources