【轉】layer彈窗 綁定回車關閉事件


原文地址:https://fly.layui.com/jie/5202/

layer.open({
  title: '回車關閉測試'
  ,content: '我是內容'
  ,btn: ['確認','關閉']
  ,success: function(layero, index){
    this.enterEsc = function(event){
      if(event.keyCode === 13){
        layer.close(index);
        return false; //阻止系統默認回車事件
      }
    };
    $(document).on('keydown', this.enterEsc);    //監聽鍵盤事件,關閉層
  }
  ,end: function(){
    $(document).off('keydown', this.enterEsc);    //解除鍵盤關閉事件
  }
});

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM