下面的html
<div class="container">
<div class="hello">hello</div>
<div class="goodbye">goodbye</div>
</div>we can target any element for removal:$('.hello').empty();this will result in a dom structure with the hello text deleted:
<div class="container">
<div class="hello"></div>
<div class="goodbye">goodbye</div>
</div>
看个实例
<!doctype html>
<html>
<head>
<style>
p { background:yellow; }
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<p>
hello, <span>person</span> <a href="网页特效:;">and person</a>
</p><button>call empty() on above paragraph</button>
<script>
$("button").click(function () {
$("p").empty();
});
</script></body>
</html>
时间: 2024-11-16 19:04:42