日期:2014-05-16  浏览次数:20313 次

jquery 操作checkbox问题
<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>


在谷歌浏览器中,点击选择后取消,再点选择就不起作用了,这是为什么?

------解决方案--------------------
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);