我的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/!
所以我的问题是删除整张桌子!不仅仅是“删除”字段!
正如你所看到的,我尝试过一些父母和兄弟姐妹,但是失败了!每一次!
编辑:
所以在这里我有最新的杂乱无章的你的建议。你的意思是先加一个'tr‘!但它仍然删除我的‘选择’元素,什么不应该是!
发布于 2013-05-29 19:16:20
替换
$(this).remove();使用
$(this).closest("table").remove();https://stackoverflow.com/questions/16822031
复制相似问题