首选区分一下prop与attr的差别。prop是固有属性,attr自定义属性。
$("#all").click(function () {//全选、反选
if(this.checked) {
$("#dynamic-table tbody :checkbox").prop(\'checked\', true);
} else {
$("#dynamic-table tbody :checkbox").prop(\'checked\', false);
}
});
$("#btn-to-report").click(function () {
var list = [];
$("#dynamic-table tbody :checkbox").each(function (i) {
var _this = $(this);
var checked = _this.prop(\'checked\');
if(checked)
list[i] = _this.val();
});
var ids = list.join(\',\');
alert(ids);
});