javascript - Jquery :: How can I delete content of div <div>...<li>sdsds<li>...div&

How can I delete content of div with jquery? example of div id container input:<div id="contain

How can I delete content of div with jquery?

example of div id container

input:

<div id="container">
<h1>sdsdsdsd</h1>
dsdsdsdsds
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
dsfdfsd
</div>

output:

<div id="container">   
 </div>

Thanks

How can I delete content of div with jquery?

example of div id container

input:

<div id="container">
<h1>sdsdsdsd</h1>
dsdsdsdsds
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
dsfdfsd
</div>

output:

<div id="container">   
 </div>

Thanks

Share Improve this question asked Jul 9, 2010 at 11:15 BenBen 25.8k35 gold badges113 silver badges166 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

Use .empty(), like this:

$("#container").empty();

You can give it a test here, it's important to use .empty() or .remove() when you have events/data bound to any descendants inside what you're clearing...otherwise you're leaking memory that won't be cleaned up.

$("#container").empty()

http://api.jquery./empty/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745209409a4616747.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信