Jquery 中 $('obj').attr('checked',true)失效的几种解决方案
1、$('obj').prop('checked',true)
2、
$(':checkbox').each(function(){
this.checked=true;
})
为什么:attr为失效?因为checked属于为原型对象的属性。而attr在remove原型对象时会出错。原型对象指的是自身自带的,无法移除。prop会忽略这个错误。而attr操作的是普通非原型对
转载
2015-11-18 10:30:53 ·
9327 阅读 ·
0 评论