今天在做项目用到了全选功能,发现不能用了,检查代码发现
/**
* 全选
*/
checkAll:function(event){
var entityName=event.data.entityName;
var checkboxes=$("table input[name='"+entittyName+".id'][disabled!='disabled']");
var flag=$(this).attr("checked");
$.each(checkboxes,function(index){
$(this).attr("checked",flag);
});
},
.attr("checked")总是undefined
As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set. In addition, .attr() should not be used on plain objects, arrays, the window, or the document. To retrieve and change DOM properties, use the .prop()method.
后把.attr("checked")改为.prop("checked")即可