转自:jQuery empty() vs remove()

 

  • empty() will remove all the contents of the selection.
  • remove() will remove the selection and its contents.
<div>
    <p><strong>foo</strong></p>
</div>

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

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

 

相关文章:

  • 2021-12-15
  • 2021-09-30
  • 2021-12-03
  • 2022-01-29
  • 2021-12-05
  • 2021-05-20
  • 2021-09-07
猜你喜欢
  • 2021-12-05
  • 2021-12-10
  • 2022-12-23
  • 2022-01-06
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案