MUI H5+常见控件的使用之单选按钮

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u014117094/article/details/78351078

单选


<label>性别</label>
<div style="float: left; width: 30%;" class="mui-radio">
	<label>男</label>
	<input id="Gender_male" name="gender" class="gender" disabled="disabled" type="radio" checked="true" />
</div>
<div style="float: left; width: 30%" class="mui-radio">
	<label>女</label>
	<input id="Gender_female" name="gender" class="gender" disabled="disabled" type="radio">
</div>

var genderMale = document.getElementById('Gender_male'); //男
var genderFemale = document.getElementById('Gender_female'); //女


Get

var data = {
Gender: getRadioValue('gender'),
function getRadioValue(className){
    var rdsObj = document.getElementsByClassName(className);
    var checkVal = null;
    for(i = 0; i < rdsObj.length; i++){
        if(rdsObj[i].checked){checkVal = rdsObj[i].value;}
    }
    if(checkVal=='on'){
    	return 1;
    }else{
    	return 0;
    }  
}




Set 

if(result.userInfo.Gender == 1) {
	genderMale.checked = true;
}
if(result.userInfo.Gender == 0) {
	genderFemale.checked = true;
}


展开阅读全文

没有更多推荐了,返回首页