说明:本文来自新浪博客,因为无法收藏,故直接copy过来备注,以后好查询 原网址:http://blog.sina.com.cn/s/blog_6810dfc20101jddq.html 使用jQuery v1.10.2获取checkbox的状态时,用.attr("checked")时输出总是为undefined.郁闷了,这难道是个bug?! 查看jQuery API的文档,发现: As of jQuery 1.6, the .attr() method returns undefin
项目中用的jquery1.9 今天需要检测一个checkbox的选中状态,想当然的用 .attr("checked") ,结果发现,无论是否选中,这个值都是 undefined 未定义. 折腾了半天,无奈,只能取jq官网看看文档,发现有这么一段说明 As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set. In addition, .attr() shoul
问题描述:使用jQuery来控制checkbox的选中状态,但是第一次点击出现选中样式,之后点击可以看到checked的属性增加成功但是并没有选 中状态. 问题代码: function chooseAllOrNot(id){ var choose=$("input[name='"+id+"']").attr('checked'); if(choose=='checked'){ $("input[type=checkbox][name='"+id+