<p>This method removes not only child (and other descendant) elements, but also any text within the set of matched elements. This is because, according to the DOM specification, any string of text within an element is considered a child node of that element. Consider the following HTML:</p>
<pre><div class="container">
<div class="hello">Hello</div>
<div class="goodbye">Goodbye</div>
</div></pre>
<p>We can target any element for removal:</p>
<pre>$('.hello').empty();</pre>
<p>This will result in a DOM structure with the <code>Hello</code> text deleted:</p>
<pre><div class="container">
<div class="hello"></div>
<div class="goodbye">Goodbye</div>
</div></pre>
<p>If we had any number of nested elements inside <code><div class="hello"></code>, they would be removed, too. Other jQuery constructs such as data or event handlers are erased as well.</p>