我有一个动态表,有唯一的行id,例如,也有每行的复选框。
我使用jquery获取该复选框的所有选定i(逗号分隔,例如1,25,4)。在jquery成功之后,我所需要的就是删除那些选中的tr。请参阅我的以下代码:
正在获取逗号分隔的ids:
var ids = $(".chk:checked").map(function() {
                    return this.id;
                }).get().join(",");条件:
if(response == 0){
                            alert('Sorry! There is some problem in server, try again.');
                            return false;
                        }else {
                            alert("Successfully removed from library.");
                            $('#tr_'+ids).remove();
                        }

发布于 2018-12-19 21:46:52
如果将所有ids添加到一个数组中,则可以使用此命令删除行
$.each(ids, function(key, val){
    $('#tr_' + val).remove();
});发布于 2018-12-19 21:43:06
$('#tr_'+ids)最终将类似于$('#tr_1,3,7,9'),这是一个无效的选择器
你可以这样做:
$("tr").has('.chk:checked').remove()
// OR 
$(".chk:checked").closest('tr').remove()https://stackoverflow.com/questions/53852226
复制相似问题