[color=green][size=medium][b]jQuery empty() vs remove()[/b][/size][/color]
What's the difference between empty() and remove()methods in jQuery, and when we call any of these methods, the objects being created will be destroyed and memory released?
----------------------------------------------------------------------------------
- empty() will remove all the contents of the selection.
- remove() will remove the selection and its contents.
Consider:
-
jquery-empty-vs-remove
http://stackoverflow.com/questions/3090662
---
-
What's the difference between empty() and remove()methods in jQuery, and when we call any of these methods, the objects being created will be destroyed and memory released?
----------------------------------------------------------------------------------
- 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>"
-
jquery-empty-vs-remove
http://stackoverflow.com/questions/3090662
---
-
本文探讨了 jQuery 中 empty() 和 remove() 方法的区别。empty() 方法用于清空被选元素的内容,而 remove() 方法则会移除被选元素及其所有内容。通过实例说明了两种方法的应用场景。

1111

被折叠的 条评论
为什么被折叠?



