jquery 操作checkbox问题

wozuozhu52p 2013-08-03 01:32:44
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="../scripts/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
     $(function () {
$("#Button1").click(function () {
$("#CheckBox1").attr("checked", "checked");
})
$("#Button2").click(function () {
$("#CheckBox1").attr("checked", false);
})
})
</script>
</head>
<body>
<div>
<input id="CheckBox1" type="checkbox" />
<input id="Button1" type="button" value="选择" />
<input id="Button2" type="button" value="取消" />
</div>
</body>
</html>


在谷歌浏览器中,点击选择后取消,再点选择就不起作用了,这是为什么?
...全文
52 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wozuozhu52p 2013-08-03
  • 打赏
  • 举报
回复
原来是版本的问题
Go 旅城通票 2013-08-03
  • 打赏
  • 举报
回复
1.4.2 的jquery没问题。。
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" 

src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
            $(function () {
    $("#Button1").click(function () {
        $("#CheckBox1").attr("checked", "checked");
    })
    $("#Button2").click(function () {
        $("#CheckBox1").attr("checked", false);
    })
})
    </script>
</head>
<body>
    <div>
        <input id="CheckBox1" type="checkbox" />
        <input id="Button1" type="button" value="选择" />
        <input id="Button2" type="button" value="取消" />
    </div>
</body>
</html>

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧