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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

如下代碼中,用detach刪除了之后,再添加沒有觸發(fā)點擊事件

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>jQuery刪除節(jié)點之empty</title>

<style type="text/css">

#box1{

background-color:lightskyblue;

}

#box2{

width:100px;

height:50px;

background-color:pink;

}

#box3{

width:60px;

height:25px;

background-color:yellow;

}

</style>

<script src="jQuery/jquery-3.3.1.js"></script>

?<script>

$(document).ready(function(){

$("#box2").click(function(){

alert("觸發(fā)了點擊事件");

});

$("#btn1").click(function(){

$("#box2").detach();

});

$("#btn2").click(function(){

$("#box1").append("<div id='box2'><div id='box3'>12345</div></div>");

});

});

?</script>

</head>


<body>

<p>文檔的一行文字</p>

<div id="box1">

<p>div的第一個子元素</p>

<p>div的第二個子元素</p>

<div id="box2">

<div id="box3">12345</div>

</div>

</div>

<button id="btn1">我可以刪除子元素哦</button>

<button id="btn2">我可以增加子元素哦</button>

</body>

</html>


正在回答

1 回答


? ?




<html>


<head>

? ? ?<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

? ? <script src="http://idcbgp.cn/static/lib/jquery/1.9.1/jquery.js"></script>



<meta charset="UTF-8">


<title>jQuery刪除節(jié)點之empty</title>


<style type="text/css">


#box1{


background-color:lightskyblue;


}


#box2{


width:100px;


height:50px;


background-color:pink;


}


#box3{


width:60px;


height:25px;


background-color:yellow;


}


</style>


<script src="jQuery/jquery-3.3.1.js"></script>


?<script>

var b;

$(document).ready(function(){


$("#box2").click(function(){


alert("觸發(fā)了點擊事件");


});


$("#btn1").click(function(){


b = $("#box2").detach();


});


$("#btn2").click(function(){


$("#box1").append(b);


});


});


?</script>


</head>




<body>


<p>文檔的一行文字</p>


<div id="box1">


<p>div的第一個子元素</p>


<p>div的第二個子元素</p>


<div id="box2">


<div id="box3">12345</div>


</div>


</div>


<button id="btn1">我可以刪除子元素哦</button>


<button id="btn2">我可以增加子元素哦</button>


</body>


</html>

定義一個全局變量就可以了

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

如下代碼中,用detach刪除了之后,再添加沒有觸發(fā)點擊事件

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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