许多数据 2015-07-29 09:30 采纳率: 0%
浏览 6772
已采纳

求解 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>
  • 写回答

14条回答 默认 最新

  • danielinbiti 2015-07-29 09:42
    关注
     if ($(this).value == "true"
     改成
     if (this.value == "true"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(13条)

报告相同问题?