$("input").attr("checked");
<input type="checkbox" value="1" />
今天遇到这样个小问题html
而后一直输出undefined 和 checked;spa
检查了不少遍也没发现问题code
而后网上找资料发现大多都是orm
if($"#xxx".attr("checked")=="true")
if($("#xxx").attr("checked")==true)
要么是这种htm
alert( $("input").attr("checked") );
alert( $("input")[0].checked );
而后既然遇到了就想办法解决咯blog
翻手册。。。而后看看手册上也是这种鬼ip
<input type='checkbox'/> <script> //获取是否选中 var isChecked = $('input').attr('checked'); //设置选中 $('input').attr('checked',true); </script>
而后这个时候终于想到了版本特性get
检查下JQ的版本1.8.。。革命性的一代input
而后寻找与以前版本的差别form
prop()获取匹配的元素的属性值
最后
$("input").prop("checked"); //true
棒棒哒
最后附上我本身搞得一个小的表格列表。。。有的功能还在制做中!!!