jQuery使用empty()方法删除元素及其所有子元素的方法
本文实例讲述了jQuery使用empty()方法删除元素及其所有子元素的方法。分享给大家供大家参考。具体实现方法如下:
<!DOCTYPEhtml>
<html>
<head>
<scriptsrc="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").empty();
});
});
</script>
</head>
<body>
<divid="div1"style="height:100px;width:300px;border:1pxsolidblack;background-color:yellow;">
Thisissometextinthediv.
<p>Thisisaparagraphinthediv.</p>
<p>Thisisanotherparagraphinthediv.</p>
</div>
<br>
<button>Emptythedivelement</button>
</body>
</html>
希望本文所述对大家的jQuery程序设计有所帮助。