问题描述:全选功能 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'));
参考: http://www.imuum.com/jquery-more-than-1-9-times-click-on-the-checkbox-cannot-be-selected.html htm