欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

layer.open 獲取不到表單信息的解決方法

 更新時(shí)間:2019年09月26日 09:38:32   作者:yi好快的刀  
今天小編大家分享一篇layer.open 獲取不到表單信息的解決方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧

表單:

<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>看房時(shí)間</span>
      <input type="text" class="input-normal order-time" name="time" placeholder="請選擇看房時(shí)間"/>
    </li>
    <li>
      <span>聯(lián)系方式</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: [
    '申請預(yù)約看房',
    '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());
    });
  }
});

在此處報(bào)了一個(gè)錯(cuò)誤:layer.open彈出框不能獲取input框的值為空

點(diǎn)擊保存就是不能獲取input的值,總是為空字符串。

后來在網(wǎng)上查找資料,原來這是個(gè)比較普遍的bug,原來是layer.open的content參數(shù)(上面紅色標(biāo)記代碼),應(yīng)該寫成

content: $('.orderHouse'),不要后面的html(),去掉后調(diào)試正常獲取了input的值,解決問題就行,也沒有去深究這個(gè)是什么原因(關(guān)鍵也沒那個(gè)時(shí)間)。

以上這篇layer.open 獲取不到表單信息的解決方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論