第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

3個相同的div,怎么獲取到點擊的div,并刪除他?JS

3個相同的div,怎么獲取到點擊的div,并刪除他?JS

19990000 2017-10-02 22:31:11
<!DOCTYPE?html> <html?lang="en"> <head> ????<meta?charset="UTF-8"> ????<title>Title</title> ????<style> ????????div{ ????????????width:80px; ????????????height:80px; ????????????border:1px?solid?#000; ????????} ????</style> </head> <body> <div?class="aaa"?id="p1"> ????<span>111</span> ????</div> <div?class="aaa"?id="p2"> ????<span>333</span> </div> <div?class="aaa"?id="p3"> ????<span>2222</span> </div> </body> </html>
查看完整描述

3 回答

已采納
?
千秋此意

TA貢獻158條經(jīng)驗 獲得超188個贊

<!DOCTYPE?html>
<html>

<head>
????<meta?charset="UTF-8">
????<title>Title</title>
????<style>
????div?{
????????width:?80px;
????????height:?80px;
????????border:?1px?solid?#000;
????}
????</style>
</head>

<body>
????<div?id="p1">
????????<span>111</span>
????</div>
????<div?id="p2">
????????<span>333</span>
????</div>
????<div?id="p3">
????????<span>2222</span>
????</div>
</body>
<script>
????var?divs?=?document.querySelectorAll('div');

????for?(var?i?=?0;?i?<?divs.length;?i++)?{
????????divs[i].onclick?=?function()?{
????????????this.parentNode.removeChild(this);
????????}
????}
</script>

</html>
查看完整回答
2 反對 回復(fù) 2017-10-02
?
信者得救

TA貢獻22條經(jīng)驗 獲得超10個贊

????document.body.addEventListener('click',?function(event)?{
????????if?(event.target.nodeName?===?'DIV')?{
????????????event.target.parentNode.removeChild(event.target);
????????}
????});


查看完整回答
1 反對 回復(fù) 2017-10-02
  • 3 回答
  • 0 關(guān)注
  • 2032 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號