checkBox的change实例

根据父checkbox的选中与取消,同时改变子checkbox
$(document).ready(function(){
        $(".channel").each(function(){
            
            $(this).change(function(){    
                var checked = $(this).attr("checked")
                var value = $(this).val();
                if(checked==undefined || checked != "checked"){
                    $(this).attr("checked","checked");
                    checked = "true";
                }else{
                    $(this).removeAttr("checked");
                    checked = "false";
                }
        //根据父checkbox获取子checkbox       
                if(checked != "false")
                {
                $.ajax({
                      type: "POST",
                        url: "querySub.do?value="+value,
                    data: "value",
                     dataType: "json",
                         success: function(msg){
                             if(msg.length!=0){
                        /*  for(var i=0; i"+msg[i].description+"  ";
                        $("#childChannel").append(html);
                    }
                    
                    }
                     }
            });


            }else{

//    取消时移除子checkbox

                $.ajax({
                          type: "POST",
                        url: "querySub.do?value="+value,
                        data: "value",
                         dataType: "json",
                             success: function(msg){                 
                                 if(msg.length!=0){    
                         for(var i=0; i


你可能感兴趣的:(checkBox的change实例)