layui的单选框radio赋选中的值

  • Post author:
  • Post category:其他


//单选框
 <input type="radio" name="radio_bnt_wid" id="radio_bnt_wid_1" >
 <input type="radio" name="radio_bnt_wid" id="radio_bnt_wid_2" >
 <input type="radio" name="radio_bnt_wid" id="radio_bnt_wid_3" >
 <input type="radio" name="radio_bnt_wid" id="radio_bnt_wid_4" >
//js代码
//选中的状态
let state = 2;
$('#radio_bnt_wid_'+state+'').attr("checked", true);//设置属性为true
form.render();//表单重新渲染一遍,最重要的,否则无效

在这里插入图片描述



版权声明:本文为yuzheh521原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。