layer.open 获取不到表单信息

匿名 (未验证) 提交于 2019-12-03 00:29:01

表单:

<div class="orderHouse none">     <ul class="order-house-messige">         <form id="order-form" class="mui-input-group common-input-group order-house-group" data-action="<{:U('ordering')}>">         <li>             <span></span>             <input type="text" class="input-normal order-time" name="time" placeholder=""/>         </li>         <li>             <span></span>             <input type="tel" class="input-normal" data-value="123123" name="mobile" placeholder="155****5892" />         </li>         <li>             <span class="fn-left"></span>             <textarea rows="5" cols="54" name="content" placeholder=""></textarea>         </li>         <li>             <span> &nbsp;</span>             <button type="button" class="btn btn-primary btn-lg order-messige-btn"></button>         </li>         </form>     </ul> </div>

js :

layer.open({     type: 1,     title: [         '',         'background-color:#fff; border-bottom:solid 1px #e5e5e5; margin-top: 0;height: 60px;line-height: 60px; font-size:18px;'     ],     closeBtn:2,     area: ['570px','400px'],     content: $('.orderHouse').html(),     success:function(){         //        $('.order-messige-btn').on('click',function() {             alert($("textarea").val());         });     } });

在此处报了一个错误:layer.open弹出框不能获取input框的值为空

点击保存就是不能获取input的值,总是为空字符串。

后来在网上查找资料,原来这是个比较普遍的bug,原来是layer.open的content参数(上面红色标记代码),应该写成

content: $('.orderHouse'),不要后面的html(),去掉后调试正常获取了input的值,解决问题就行,也没有去深究这个是什么原因(关键也没那个时间)。

https://blog.csdn.net/jaryle/article/details/79814298



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!