<label>登记类型:</label> <div class="kk-complaint-radio kk-claerfix"> <div class="mui-radio mui-pull-left"> <input name="radio1" value="1" type="radio" > <label>投诉</label> </div> <div class="mui-radio mui-pull-left"> <input name="radio1" value="2" type="radio"> <label>举报</label> </div> </div>
js赋值:
var ele1 = document.getElementsByName("radio1"); ele1[0].checked=true;
jquery赋值
$("input[type='radio1']").eq(0).prop("checked",true);//默认选中有
$("input[name='radio1'][value='2']").attr("checked",true);
获取当前用户选中的值
function getRadioRes(className) { var rdsObj = document.getElementsByName(className); var chackVal = null; for(i = 0; i < rdsObj.length; i++) { if (rdsObj[i].checked) { chackVal = rdsObj[i].value; } } return chackVal; } var regType = getRadioRes("radio1");
COCO 很懒 什么都没留下。。。