jquery 根据后台传过来的值动态设置下拉框、单选框选中

2021-07-02 00:07

阅读:863

标签:var   jquery   html   attr   ack   ted   ati   blog   color   

jquery  根据后台传过来的值动态设置下拉框、单选框选中

 1 $(function(){
 2     var sex=$("#sex").val();
 3     var marriageStatus=$("#marriageStatus").val();
 4     var education=$("#education").val();
 5     if(!isnull(sex)){
 6         //$("input:radio[name=‘sex‘][value="+sex+"]").attr(‘checked‘,‘true‘);
 7         $("input:radio[name=‘sex‘][value="+sex+"]").prop(‘checked‘,‘true‘);
 8     }
 9     if(!isnull(marriageStatus)){
10         //$("input:radio[name=‘marriageStatus‘][value="+marriageStatus+"]").attr(‘checked‘,‘true‘);
11         $("input:radio[name=‘marriageStatus‘][value="+marriageStatus+"]").prop(‘checked‘,‘true‘);
12     }
13     //if(!isnull(education)){
14     //    $("#education1 option[value=‘"+education+"‘]").attr("selected", true);
15     //}
16     $("#education1").val(education);
17     
18 });
19 20 21 22 23 24 25 26 

 

 

jquery 根据后台传过来的值动态设置下拉框、单选框选中

标签:var   jquery   html   attr   ack   ted   ati   blog   color   

原文地址:http://www.cnblogs.com/manzb/p/7131300.html


评论


亲,登录后才可以留言!