vue使用input:radio实现单选,并默认选中数据库中的值
jsp:<div class="radio-box"><input name="sex" type="radio" value="0" checked><label>男</label></div><div class="radio-box"><input name="sex" typ...
·
jsp:
<div class="radio-box">
<input name="sex" type="radio" value="0" checked>
<label>男</label>
</div>
<div class="radio-box">
<input name="sex" type="radio"value="1">
<label>女</label>
</div>
vue获取值:
queryDate: function () {
let that = this;
$.ajax({
type: 'post',
url: "${ctx}/operator/operationOne",
dataType: "JSON",
data: {"operId": that.operId},
success: (res) => {
if (res.state) {
let result = res.result;
$('input[name=sex][value=' + result.gender + ']').iCheck('check');
}
}
});
},
保存时取选中值:
let gender=$("input[name='sex']:checked").val();
更多推荐
已为社区贡献2条内容
所有评论(0)