Sunday, 22 July 2012

difference in empty() and remove()


  • Empty will remove all the contents of the selection.
  • Remove will remove the selection and its contents.
Consider:
<div>
    <p><strong>foo</strong></p>
</div>

$('p').empty();  // --> "<div><p></p></div>"

// whereas,
$('p').remove(); // --> "<div></div>"

No comments:

Post a Comment