背景:多个选项中只能选一个,且可以取消选中。第二张图为取消后,鼠标悬浮效果,移开就没有蓝色样式了。
html代码:
<input type="radio" name="isHibition" lay-filter="isHibition" lay-skin="primary" checked="">
直接将下面的代码复制就好了,注意isHibition为我的单选组名,根据需要改成自己起的名字。
form.on('radio(isHibition)', function (data) {
if($(this).attr("checked")) {
$(this).removeAttr("checked")
form.render();
} else {
$(this).attr("checked", "true")
form.render();
}
})
这样能正常切换单选,在选中时也能再次点击取消选中