layer的alert、prompt等操作如何響應鍵盤的回車和ESC操作


 

 

        layer.prompt({title: '請輸入數據', 
       formType: 1, //隱藏用戶輸入內容 // 這個是確定按鈕的事件 "success":function(){ // 鍵盤事件,判斷回車 $("input.layui-layer-input").on('keydown',function(e){ if (e.which == 13) { // 取輸入框數據 和123456 比較 if("123456" == $(this).val()){ alert('你點擊了回車按鈕!'); layer.close(1); } } }); }, // 點擊確定按鈕事件 yes : function(){ // 取輸入框數據 var pass =$(document.getElementsByClassName('layui-layer-input')[0]).val(); if("123456" == pass){ alert('你點擊了確定按鈕!');s layer.close(1); } } });

轉載:https://blog.csdn.net/haiyuexinming/article/details/78130668

參考:https://www.jianshu.com/p/86665d0398d4


免責聲明!

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



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