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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

用的jquery 為什么能動(dòng)態(tài)添加 不能動(dòng)態(tài)刪除?

動(dòng)態(tài)添加的行不能刪除,原來(lái)的行可以刪除



<!DOCTYPE html>

<html>

?<head>

? <title> new document </title> ?

? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ??

? <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>

??

?</head>?

?<body>?


? <table border="3" width="50%" id="table">

? <tr>

<th>學(xué)號(hào)</th>

<th>姓名</th>

<th>操作</th>

? </tr> ?


? <tr>

<td>xh001</td>

<td>王小明</td>

<td><a>刪除</a></td> ? <!--在刪除按鈕上添加點(diǎn)擊事件 ?-->

? </tr>


? <tr>

<td>xh002</td>

<td>劉小芳</td>

<td class='sd' ><a>刪除</a></td> ? <!--在刪除按鈕上添加點(diǎn)擊事件 ?-->

? </tr> ?


? </table>

? <input ?type="button" value="添加一行" onclick="add()" /> ? <!--在添加按鈕上添加點(diǎn)擊事件 ?-->

? ? ? ?<script type="text/javascript">?

? ? ? ? var div1 ="<tr><td>xh002</td><td>劉小芳</td><td><a>刪除</a></td></tr>"

? ? ? ? $('input').click(function(){

? ? ? ? ? ? //alert("dsfsfd")?

? ? ? ? ? ? $('table').append(div1);

? ? ? ? })

? ? ? ? $("a").on('click',function(){

? ? ? ? ? ? $(this).parents('tr').remove();

? ? ? ? })

? ? ??


? </script>

?</body>

</html>


正在回答

1 回答

新添加的行,a標(biāo)簽沒(méi)有并沒(méi)有添加事件,

$('input').click(function() {

//alert("dsfsfd")?

$('table').append(div1);

$("a").on('click', function() {

$(this).parents('tr').remove();

})

})

$("a").on('click', function() {

$(this).parents('tr').remove();

})


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

小彩筆輕松 提問(wèn)者

改成事件代理就好了,沒(méi)看懂你發(fā)的代碼啥意思 改成$("table").on('click','a',function(){ $(this).parents('tr').remove(); })
2016-10-13 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

用的jquery 為什么能動(dòng)態(tài)添加 不能動(dòng)態(tài)刪除?

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

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

幫助反饋 APP下載

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

公眾號(hào)

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