jQuery Tutorial Tutorials - jQuery .empty() method

jQuery .empty() method

The .empty() method in jQuery is used to remove all child nodes of the matched elements from the DOM.

jQuery .empty() method Syntax

.empty()

jQuery .empty() method Example

Removes 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>

Try now

Date:2019-08-21 12:26:42 From:www.Lautturi.com author:Lautturi