jQuery使用empty()方法删除元素及其所有子元素的方法
更新时间:2015年03月26日 12:03:46 作者:上大王
这篇文章主要介绍了jQuery使用empty()方法删除元素及其所有子元素的方法,涉及jQuery操作元素的技巧,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了jQuery使用empty()方法删除元素及其所有子元素的方法。分享给大家供大家参考。具体实现方法如下:
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").empty();
});
});
</script>
</head>
<body>
<div id="div1" style="height:100px;width:300px;border:1px solid black;background-color:yellow;">
This is some text in the div.
<p>This is a paragraph in the div.</p>
<p>This is another paragraph in the div.</p>
</div>
<br>
<button>Empty the div element</button>
</body>
</html>
希望本文所述对大家的jQuery程序设计有所帮助。
您可能感兴趣的文章:
相关文章
jQuery使用addClass()方法给元素添加多个class样式
这篇文章主要介绍了jQuery使用addClass()方法给元素添加多个class样式的方法,实例分析了addClass方法的使用技巧及添加多个样式的实现方法,需要的朋友可以参考下2015-03-03


最新评论