原文地址: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); //解除鍵盤關閉事件 } });
