0

我的 jQuery 代码有问题!

function handleChange2() {

var table = $('#condition').append($('<table>'));
var data = $(this).val();

table.append($('<td>').text(data));
table.append($('<td>').text('Delete').mousedown(deleteRow));

};

function deleteRow() {

$(this).remove();
//$(this).siblings('td').remove();
//$(this).parent('table').remove();


}

这是一个 jsFiddle:http: //jsfiddle.net/Codehunter/cL3s2/4/

所以我的问题是删除整个表!不仅仅是“删除”字段!

如您所见,我尝试了一些父母和兄弟姐妹,但失败了!每一次!

编辑 :

所以在这里我有更新的 jsfiddle 和你的建议。首先添加“tr”是什么意思!但它仍然删除了我的“选择”元素,什么不应该!

http://jsfiddle.net/Codehunter/cL3s2/12/

4

1 回答 1

0

代替

$(this).remove();

$(this).closest("table").remove();
于 2013-05-29T19:16:20.370 回答