select 动态赋值 layui重新渲染

select下拉框

   <select id="ZhiWuErJi" class="layui-input " type1="flow_select" isflow="1" required="required" name="ZhiWuErJi">
  </select>

Js

   $(window).load(function () {
         
        var q1 = document.getElementById("ZhiJi");
        console.log(q1.options.length);
        for (var i = 0; i < q1.options.length; i++) {
            if (q1.options[i].value == "@info.ZhiJi") {
                q1.options[i].selected = true;
            }
        }
    //layui重新渲染
      layui.use('form', function(){
           var form = layui.form;//高版本建议把括号去掉,有的低版本,需要加()
           form.render('select');
           //form.render();
       });
  ==========================================================或者==============================================================
  $("#ZhiWuErJi").val(值); //直接赋值
}

 

posted @ 2019-12-24 17:57  幽冥狂_七  阅读(19836)  评论(0编辑  收藏  举报