layer.open({
                title:'添加管理员',
                type: 1,
                content: $('.add_html').html(), 
                btn:['添加', '取消'],
                btnAlign:'c',
                yes:function (index, layero) {
                    console.log($('input[name=user_name]').val());
                }
            });

一句话, 把 content参数的 html() 去掉就好, 即 content: $('.add_html') !

 

如果用 val() 还获取不到值,尝试用 $('input[name=user_name]').attr("value") 或者 $('input[name=user_name]').prop("value") 获取,这两种获取方式要在 input框html代码 写上 value=‘ ’

<input class="layui-input" value="" type="text">  // 写上 value=''

 

 

另外,  去掉html()后,一定要加上弹窗的类型 type:1, 不然弹窗出现这种形式:

layui  layer.open弹出框获取不了 input框的值

 

相关文章:

  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2021-10-12
猜你喜欢
  • 2021-05-08
  • 2021-06-29
  • 2021-08-06
  • 2022-12-23
相关资源
相似解决方案