layui 实现自动选择radio单选框(checked)

HTML表单:

JS用ajax去后端取回数据:

$.get(    
        "{:url('user/xxxx')}",
        {'id':adminId},
        function(d){
              //设置是否通知
              if(d.is_notice == 0){
                    $("input[name=is_notice][value=1]").prop("checked","false");
                    $("input[name=is_notice][value=0]").prop("checked","true");
               }
               form.render(); //更新全部
         }
);

切记最后的form.render(); 不能漏

(layui使用之前引入操作省略)

mark it.

你可能感兴趣的:(layui)