jQuery使用empty()方法删除元素及其所有子元素的方法
作者:bea
本文实例讲述了jQuery使用empty()方法删除元素及其所有子元素的方法。分享给大家供大家参考。具体实现方法如下: <!DOCTYPE html><html><head><script src="js/jquery.min.js"></script><script>$(document).ready(function(){ $("button").click(function(){ $("#di
本文实例讲述了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调用绑定click事件的3种写法
- 对Web开发中前端框架与前端类库的一些思考
- Javascript优化技巧之短路表达式详细介绍
- 学习JavaScript编程语言的8张思维导图分享
- JavaScript中的函数声明和函数表达式区别浅析
- jQuery使用fadein方法实现渐出效果实例
- jQuery使用fadeout实现元素渐隐效果的方法
- javascript包装对象实例分析
- javascript操作select元素实例分析
- jquery使用slideDown实现模块缓慢拉出效果的方法
- jQuery使用slideUp方法实现控制元素缓慢收起
- jquery使用animate方法实现控制元素移动
- jQuery获取标签文本内容和html内容的方法
- Node.js 去掉种子(torrent)文件里的邪恶信息
- jQuery使用attr()方法同时设置多个属性值用法实例
- jQuery使用prepend()方法在元素前添加内容用法实例
- jQuery使用append在html元素后同时添加多项内容的方法
- jQuery使用before()和after()在元素前后添加内容的方法
- jQuery使用after()方法在元素后面添加多项内容的方法