<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");
原文地址:https://www.cnblogs.com/xkoko/p/9663482.html
时间: 2024-10-31 02:56:40