admin管理员组文章数量:1303536
I am using Lean Modal for a Modal on my web app.
Lean Modal Website: /
Its all working fine. I just want to add the event "Esc Button Click" which closes the modal. How can I do it? Please advise.
I am using Lean Modal for a Modal on my web app.
Lean Modal Website: http://leanmodal.finelysliced..au/
Its all working fine. I just want to add the event "Esc Button Click" which closes the modal. How can I do it? Please advise.
Share asked Sep 27, 2013 at 7:23 Pratik PoddarPratik Poddar 1,3453 gold badges18 silver badges36 bronze badges3 Answers
Reset to default 5Based on the demos on their homepage, you can close the modal by clicking outside it. You just need to trigger the same click event when ESC key is pressed. This ensures that the closing is actually done by the plugin itself and not by you.
$(document).keyup(function(ev){
if(ev.keyCode == 27)
$("#lean_overlay").trigger("click");
});
Do something like
$(window).bind('keyup',function(e){
if(e.keyCode == 27)
$('#signup,#lean_overlay').fadeOut();
})
For the example on demo page
<a href id="modal" tabindex="-1" >Click to open </a>
add tabindex="-1" if you are using jquery .
本文标签: javascriptModal (LeanModal) Close by Esc KeyStack Overflow
版权声明:本文标题:javascript - Modal (LeanModal) Close by Esc Key - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741689922a2392662.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论