本帖最后由 net_lover 于 2013-12-21 21:14:59 编辑

解决方案 »

  1.   

    $('label').click
    改成
    $('.box-all').change
      

  2.   


    你什么版本的浏览器啊?我FF,ie8都通过测试
      

  3.   

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="x-ua-compatible" content="ie=7" />
    <title>test page</title>
    <script language="javascript" type="text/javascript" src="./plugins/jq1.10.2.js"></script>
    <script language="javascript" type="text/javascript">
    $(document).ready(function(){
        $('label').click(function(){
    $(".box-items").each(function(){
            alert($(".box-all").attr("checked"));
                $(this).attr("checked",!!$(".box-all").attr("checked"));
            });
    });
    })</script>
    </head>
    <body>
    <label><input type="checkbox" class="box-all" /><span>全选</span></label><br>
    <input type="checkbox" class="box-items"/><br>
    <input type="checkbox" class="box-items"/><br>
    <input type="checkbox" class="box-items"/><br>
    <input type="checkbox" class="box-items"/><br>
    <input type="checkbox" class="box-items"/><br></body>
    </html>Firefox 26.0
    IETester 
    操作系统是XP SP3
    测试都弹出5个undefined 
      

  4.   


    你什么版本的浏览器啊?我FF,ie8都通过测试Firefox 26.0 IETester 都没测试通过!
      

  5.   


      我在网上也查到这种写法,但都没有测试成功,不知道是什么原因?后来自己参考别人的思路重写了代码后IE下是好的。但FF下多次点击却只显示一次全选状态,获取checked的值已被改变显示却没有改变。  麻烦帮我分析下,谢谢! 
      

  6.   

    完整的测试代码<script src="jquery-1.10.2.min.js"></script><script>
    $(function(){
    $('label').click(function(){
    $(".box-items").each(function(){
        $(this).prop("checked",!!$(".box-all").prop("checked"));
    });
    });
    });
    </script><label><input type="checkbox" class="box-all" /><span>全选</span></label><br>
    <input type="checkbox" class="box-items"/><br>
    <input type="checkbox" class="box-items"/><br>
    <input type="checkbox" class="box-items"/><br>
    <input type="checkbox" class="box-items"/><br>
    <input type="checkbox" class="box-items"/><br>注意jquery版本