checkbox

$(document).ready(function(){
            var page_id = {/$page_id/};
            var location_id = {/$location_id/};
            var locationlist = {/json_encode($location_list)/};
            addLocation(locationlist,page_id,location_id);
            $("#page_id").on('change',function(){
                addLocation(locationlist,$(this).val(),location_id);
            });
//if($("#agree").attr("checked")==true){
            $('#other').click(function(){
                if($(this).is(':checked')){
                    $(this).parent().parent().next().next().attr("disabled",false);
                } else{
                    $(this).parent().parent().next().next().attr("disabled",true);
                }
            })

            $(".desc").click(function(){
                var chkbox=$(this).parent().parent().find('input[name=description_]');
                var v="";
                for(var i=0;i<chkbox.length;i++){
                    if((i+1)!=chkbox.length){
                        if(chkbox[i].checked) v+=chkbox[i].value+",";
                    }
                }
                $(this).parent().parent().next().val(v);
            });

            $("input[name=check]").click(function(){
                if($(this).is(':checked')&&$(this).val()==2){
                    $(this).parent().next().find('.desc').attr("disabled",true);
                    $(this).parent().parent().find('#qita').attr("disabled",true);
                    $(this).parent().parent().find('#description_all').val('');
                    $(this).parent().parent().find('#qita').val('');
                    var chkbox=$(this).parent().parent().find('input[name=description_]');
                    chkbox.each(function(){
                        $(this).attr("checked",false);
                    })
                } else{
                    $(this).parent().next().find('.desc').attr("disabled",false);
                    //$(this).parent().parent().find('#qita').attr("disabled",false);
                }
            })
        });
原文地址:https://www.cnblogs.com/afei-happy/p/5650243.html