开发者社区> 问答> 正文

value="true" 的checkbox为什么不能选中

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js">

</head>
<body>
<div id="tabsList-3">
<input id = "1" type="checkbox" value="true" />
<input id = "2" type="checkbox" value="false" />
<input id = "3" type="checkbox" value="false" />
<input id = "4" type="checkbox" value="false" />
<input id = "5" type="checkbox" value="false" />
<input id = "6" type="checkbox" value="false" />
<input id = "7" type="checkbox" value="false" />
<input id = "8" type="checkbox" value="false" />
<input id = "9" type="checkbox" value="false" />

</div>
</body>
<script>
 $(document).ready(function(){
 $("#tabsList-3 input[type='checkbox']").each(function(){if ($(this).value == 

"true") {
                        $(this).attr("checked", true);}})

});

</script>
</html>

展开
收起
小旋风柴进 2016-03-12 16:46:37 1952 0
1 条回答
写回答
取消 提交回答
  • if ($(this).value == "true"
     改成
     if (this.value == "true"
    2019-07-17 19:01:12
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载