【发布时间】:2014-11-26 10:05:59
【问题描述】:
我正在制作一个页面,您可以在其中检查表格中的几行,然后将它们导出。
这里是代码http://www.bootply.com/Hrll6yz0c1
向模态导出菜单添加行的代码效果很好,但删除模态内行的代码不起作用。
删除代码
$('button#delB').click(function() {
$(this).parent().parent().remove();
});
对于这个生成的表
$('button#addB').click(function() {
var toAdd = $(this).parent().parent().find("#sub_id").html();
var toAdd2 = $(this).parent().parent().find("#val1").html();
var toAdd3 = $(this).parent().parent().find("#val2").html();
$('#tblGrid').append("<tr><td>"+toAdd+"</td><td>"+toAdd2+"</td><td>"+toAdd3+"</td><td><button type='button' class='btn btn-default glyphicon glyphicon glyphicon-remove' id='delB'></button></td></tr>");
});
我尝试使用相同的代码删除外部模式,它正在工作。
【问题讨论】:
-
请在问题中包含您的相关代码。另外,
ids 应该是唯一的! -
我怀疑您将事件处理程序绑定到绑定时不存在的按钮。以防万一,请尝试改用
on()。 -
George,我的代码有链接,有问题吗?
-
@Deniss 您链接到您的代码没有问题,只要您在问题中也包含相关代码。
标签: javascript jquery html twitter-bootstrap bootstrap-modal