Blizzard_lihe
2016-11-19 11:15:55
<!DOCTYPE?html>
<html>
<head>
<meta?charset="UTF-8">
<title>Document</title>
<script?src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
<style?type="text/css">
.left,
.right{
width:?300px;
}
.left?div,
.right?div{
width:?100px;
height:90px;
padding:?5px;
margin:?5px;
float:?left;
border:?1px?solid?#ccc;
}
.left?div{
??background:?#bbffaa;
}
.right?div{
background:?yellow;
}
</style>
</head>
<body>
?????<h2>通過empty與remove移除元素</h2>
?????<div>
??????<button?id="bt1">
??????點擊通過jQuery的empty移除內部的P元素
??????</button>
??????<button?id="bt2">
????????點擊通過jQuery的remove移除整個節點
??????</button>
?????</div>
<div>
<div?id="test1">
<p>p元素1</p>
<p>p元素2</p>
</div>
<div?id="test2">
<p>p元素3</p>
<p>p元素4</p>
</div>
</div>
<script?type="text/javascript">
$("bt1").on('click',function(){
$("#test1").empty()
})
?????$("#bt2").on('click',function(){
??????$("test2").remove()
?????})
</script>
</body>
</html>沒反應啊???
3 回答
已采納

蜂之谷
TA貢獻564條經驗 獲得超863個贊
$("#bt1").on('click',function(){?//少# $("#test1").empty(); }); $("#bt2").on('click',function(){ ????$("#test2").remove();//少# });

- 3 回答
- 0 關注
- 1663 瀏覽
相關問題推薦
添加回答
舉報
0/150
提交
取消