jQuery 1.9版本以上屡次点击checkbox没法选中的问题

问题描述:全选功能 html

代码: jquery

$("input[name='onday[]']").each(function(){
    $(this).attr('checked','checked');
});



第一次 全选和全不选 能很好的工做,但第二次开始 不能全选 this

将checked改成 true false也很差使 spa

网搜之,说是jQuery版本问题,且使用prop能很好地工做,代码更简练 code

$("input[name='onday[]']").prop('checked',$('#checkedall').prop('checked'));



so之后像checkbox,select 这种请一概使用 prop方法,good。

参考: http://www.imuum.com/jquery-more-than-1-9-times-click-on-the-checkbox-cannot-be-selected.html htm

相关文章
相关标签/搜索