js 设置radio默认选中 ゝ一纸荒年。 2022-09-21 13:17 291阅读 0赞 <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"); }
还没有评论,来说两句吧...