0
我試圖用jQuery刪除一個錶行。我使用了所有我能找到的方法,但都沒有成功。 我在每行的末尾都有一個刪除,當我點擊它時,我觸發一個函數,它應該刪除它所在的行。但它不會工作。正在刪除當前行jQuery
在評論是我的嘗試失敗。 是否存在像第一個那樣的僞造,但對於當前項目(類似這樣的)?
function del(){
//$(this).parent().parent().remove();
//$(this).closest("tr").remove();
//$('table tr:last').remove(); this one worked but it deletes the last and I want the current one to be deleted
}
這裏是生成表的代碼:
$.getJSON("nutritional_value.php?value=" + encodeURI(value), function (data) {
var ttr = $("<tr class='rou' />");
$.each(data, function(k, v){
var store_1 = v * (parseFloat(uneseno, 10)/100);
var xstore_1 = store_1.toFixed(2);
$("<td class='teedee'></td>").text(k=='name' ? v : xstore_1).appendTo(ttr);
});
$("<td id='delete' onClick='del();'>Delete</td>").appendTo(ttr);
$("#tejbl").append(ttr);
});
謝謝!完美的作品。並感謝您的額外提示:) – Filkatron