.empty()
methodThe .empty()
method in jQuery is used to remove all child nodes of the matched elements from the DOM.
.empty()
method Syntax.empty()
.empty()
method ExampleRemoves all child nodes (including text nodes) from all paragraphs
HTML
<div class="container"> <p>Learn JavaScript</p> <p>Learn jQuery <strong>on lautturi.com</strong></p> </div>
jQuery
$("p").empty();
Result
<div class="container"> <p></p> <p></p> </div>