Jquery给input[type=radio] 控件赋值
1 setobject: function (data, scope, win) { //data jsoon数据, scope,一般为form的id,win 窗口对象,如果在当前window win=null 2 $.each(data, function (id, value) { //循环json数据每个属性 3 var control; //当前控件 4 if (scope) { 5 if(win){ 6 control = $("#" + scope + " #" + id,win); 7 }else{ 8 control = $("#" + scope + " #" + id); 9 } 10 } else { 11 if(win){ 12 control = $("#" + id,win); 13 }else{ 14 control = $("#" + id); 15 } 16 17 } 18 } 19 if (control.is("input[type='radio']")) { //如果当前控件为<inpur type='radio' /> 20 $('input[name='+id+'][value='+value+']',win).attr("checked",true); 21 } 22 } 23