【发布时间】:2015-07-22 14:28:45
【问题描述】:
我有以下代码,即使选中了复选框,在第二次执行时也不会执行。请帮忙。谢谢
编辑:我刚刚添加了使用复选框检查表中哪些行的代码。很抱歉有太多代码要发布。 基本上第二次它确实得到了正确的行,但是迭代选中的复选框的第二个函数没有运行。
$('input[type=checkbox]').each(function() {
if (this.checked == true){
var del_id = $(this).parents("tr").data();
console.log('!del_id', del_id);
del_arr.push(del_id.id);
myData ={"spreadsheets_ids": del_arr};
console.log('mydata:', myData);
}
});
///OFF TO AN AJAX CALL AND LOTS OF OTHER STUFF HAPPENS
在它回到下面之前
$('input[type=checkbox]:checked').each(function() {
var $tr = $(this).closest('tr');
var del_id = $tr.attr('data-id');
console.log('STILL TO BE DELETED: =' + del_arr);
$.each(del_arr, function(index, value ) {
console.log('EVEN STILL TO BE DELETED: =' + del_arr);
if (value == del_id){
$tr.remove();
console.log('Removing :'+ del_id +' And ' + value);
return false;
}
});
})
$('input[type=checkbox]').each(function() {
$(this).prop('checked', false);
if (this.checked == true){
console.log('I am still checked')
}
});
【问题讨论】:
-
你能做一个小提琴吗?
-
not get executed是什么意思?
标签: javascript jquery checkbox datatables