$(document).ready(function(){
  /*$("#qx").toggle(function(){*/
  $("checkbox[qx]").attr("checked", true);
          $("[name=checkbox]:checkbox").attr("checked", true);
          },
          function(){
          /*$("#qx").attr("checked", false);*/
           $("[name =checkbox]:checkbox").attr("checked", false);
           }
     );
     });
大概意思就是找到id="qx"的复选框,点一下全选,再点反选,功能可以实现,但是id="qx"的复选框,始终是未选状态,加上那段注释的代码也不行,求大神帮忙看看。
分不多了,在线等,大家帮帮忙= =

解决方案 »

  1.   

    额,发上来的时候有点小错误,第一个注释其实是下面那行
     /*$("checkbox[qx]").attr("checked", true);*/
      

  2.   

    $("#qx").attr("checked",true); 
    包括$("[name=qx]:checkbox").attr("checked", true);
    这样都是不行的,我贴一下jsp代码,大家再帮忙看看,谢谢了
    <input type="checkbox" name="qx" value="checkbox" id="qx" />
          全选</span></td>
      

  3.   

    不知道你页面怎么写的,这个应该很简单的,ff调试下看看。发的jsp代码太少了 ,看不大明白http://www.happyalaric.com
      

  4.   

    你id是不是重复了?
    $("qx").each(function()
    {
     $(this).attr("checked",true);
    })
      

  5.   

    使用document.getElementById("qx").checked=true试试看,如果能行,把$(document).ready(function(){改成jQuery(document).ready(function($){
      

  6.   


    $("qx").click(function(){
        if(this.attr("checked")){
            $(".cb").attr("checked","checked");
        }else{
            $(".cb").removeAttr("checked");
        }    
    });<input type="radio" id="qx"/>
    <input type="checkbox" class="cb"/>
    <input type="checkbox" class="cb"/>
    <input type="checkbox" class="cb"/>
    <input type="checkbox" class="cb"/>
    <input type="checkbox" class="cb"/>
    这是一段非常简单的代码,感觉好像可以实现你的功能了,当然我没试,只是现写的,你可以试一下。感觉你上面的逻辑看起来好像有点复杂化了。
      

  7.   

    楼上的已经写的差不多了,不过判断是有点问题的this.attr("checked")这样取出的是checked
    还有就算取出的直是true 或者 false  if的时候也要反过来
      

  8.   

    昨天自己弄好了,其实一段代码就行了
    $("[name=checkbox]:checkbox").attr("checked", this.checked); 
    谢谢大家