如何用jquery删除div的内容?
div id 容器示例
输入:
<div id="container">
<h1>sdsdsdsd</h1>
dsdsdsdsds
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
dsfdfsd
</div>
输出:
<div id="container">
</div>
谢谢
最佳答案
使用.empty()
,像这样:
$("#container").empty();
You can give it a test here , 使用 .empty()
很重要或 .remove()
当您将事件/数据绑定(bind)到您正在清除的内容中的任何后代时……否则您将泄漏不会被清理的内存。
关于javascript - Jquery::如何删除 div <div>...<li>sdsds</li>.../div> 的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3212061/