js 设置radio默认选中

来源:互联网 发布:cdn 云计算 编辑:程序博客网 时间:2024/05/01 13:32
<p class="font">    <input type="radio" style="display:inline-block;width:21px" name="status" checked="checked" class="mg-lr10"  id="open" value="1">启用    <input type="radio" style="display:inline-block;width:21px" name="status"  class="mg-lr10"  id="close" value="0">停用 </p>$(".font").find("input[name='status']").removeAttr("checked");if ('1' == result.status){  $("#open").attr("checked","checked");} else if ('0' == result.status){  $("#close").attr("checked","checked");}<pre name="code" class="html"><input type="radio"  name="optionsRadiosinline"  value="MIDDLE_VOCATIONAL" checked> <em class="slect-1">中职</em><input type="radio" name="optionsRadiosinline" value="HIGH_VOCATIONAL" > <em class="slect-1">高职</em>input type="radio" name="optionsRadiosinline" value="REGULAR_COLLEGE"  > <em class="slect-1">本科</em>


 
if(level=='MIDDLE_VOCATIONAL'){   $("input[name='optionsRadiosinline']").eq(0).attr("checked","checked");}else if(level=='HIGH_VOCATIONAL'){   $("input[name='optionsRadiosinline']").eq(1).attr("checked","checked");}else if(level=='REGULAR_COLLEGE'){   $("input[name='optionsRadiosinline']").eq(2).attr("checked","checked");}





0 0
原创粉丝点击