网页原文:
<div class="layui-form-item layui-form-text">
<label class="layui-form-label" style="margin-right: 20px;">是否开启:</label>
<div class="layui-input-block">
<input type="radio" name="shi" value="1 " title="是" checked='' lay-filter='clic'>
<input type="radio" name="fou" value="2" title="否" lay-filter='clic'>
</div>
</div>
jq 处理 日常引入 lay-filter=‘clic’ 是控制是否选中必需品
layui.use(['form', 'jquery', ], function() {
var form = layui.form,
$ = layui.jquery;
//监听指定单选
form.on('radio(clic)', function(data) {//jq 事件筛选原则
// console.log(data)
if (data.value == 1) {
$("input[name='shi']").prop('checked', 'checked'); //否则 为是时 选为选中
$("input[name='fou']").removeProp('checked') // 为否时移除选中
form.render('radio')
} else {
$("input[name='shi']").removeProp('checked') //当为是时 移除选中
$("input[name='fou']").prop('checked', 'checked'); //当选否时 获取为选中
form.render('radio')
}
// console.log(data.elem); //得到radio原始DOM对象
// console.log(data.value); //被点击的radio的value值
});
});