課程
/前端開(kāi)發(fā)
/jQuery
/jQuery基礎(chǔ)(二)—DOM篇
為什么再次點(diǎn)擊的效果是這樣
2016-09-28
源自:jQuery基礎(chǔ)(二)—DOM篇 4-5
正在回答
$("button:last").click(function() {
? ? ? ? var p = $("p:first").detach();
? ? ? ? p.css('color','blue').text('p2通過(guò)detach處理后,點(diǎn)擊該元素事件存在')
? ? ? ? $("body").append(p);
? ? });
每點(diǎn)擊一次就會(huì)在body的最后寫(xiě)入一行‘p2通過(guò)detach處理后,點(diǎn)擊該元素事件存在'
? ? $("button:first").click(function() {
? ? ? ? var p = $("p:first").remove();
? ? ? ? p.css('color','red').text('p1通過(guò)remove處理后,點(diǎn)擊該元素,事件丟失')
? ? $("button:last").click(function() {
代碼沒(méi)看清吧
舉報(bào)
jQuery第二階段開(kāi)啟DOM修煉,了解創(chuàng)建、插入、刪除與替換
2 回答detach
1 回答detach()
3 回答detach()和remove()的區(qū)別
1 回答remove detach
2 回答.parent.html("")和.detach()的區(qū)別
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-09-28
$("button:last").click(function() {
? ? ? ? var p = $("p:first").detach();
? ? ? ? p.css('color','blue').text('p2通過(guò)detach處理后,點(diǎn)擊該元素事件存在')
? ? ? ? $("body").append(p);
? ? });
每點(diǎn)擊一次就會(huì)在body的最后寫(xiě)入一行‘p2通過(guò)detach處理后,點(diǎn)擊該元素事件存在'
2016-09-28
? ? $("button:first").click(function() {
? ? ? ? var p = $("p:first").remove();
? ? ? ? p.css('color','red').text('p1通過(guò)remove處理后,點(diǎn)擊該元素,事件丟失')
? ? ? ? $("body").append(p);
? ? });
? ? $("button:last").click(function() {
? ? ? ? var p = $("p:first").detach();
? ? ? ? p.css('color','blue').text('p2通過(guò)detach處理后,點(diǎn)擊該元素事件存在')
? ? ? ? $("body").append(p);
? ? });
代碼沒(méi)看清吧