前端基础 -JQuery 删除节点
JQuery 删除节点 删除节点有两个关键字:empty 清空、remove:移除案例:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>03_删除节点.html</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../js/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
//1.清空ul
//$("#city").empty();
//2.移除天津 remove
$("#tj").remove();
});
</script>
</head>
<body>
<ul id="city">
<li id="bj" name="beijing">北京
<p>海淀区</p>
</li>
<li id="tj" name="tianjin">天津
<p>河西区</p>
</li>
<li id="cq" name="chongqing">重庆</li>
</ul>
<p class="hello">Hello</p> how are
<p>you?</p>
</body>
<script type="text/javascript">
</script>
</html>
文档来源:51CTO技术博客https://blog.51cto.com/u_15294985/2999297
页:
[1]