在esc按键上关闭Bootstrap popover [英] Close Bootstrap popover on esc keypress
本文介绍了在esc按键上关闭Bootstrap popover的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 ESC 键关闭引导程序弹出窗口.
I am trying to close bootstrap popover using ESC key press.
但是在使用时似乎无效:
But it does not seem to be working when using:
$(document).keyup(function (event) {
if (event.which === 27) {
$('#example').popover('hide');
}
});
这是带有自举弹出窗口的小提琴:
Here is the fiddle with bootstrap popover:
http://jsfiddle.net/mashinista/b2NKt/
推荐答案
您包含的小提琴有弹出代码,但没有转义代码.
The fiddle you included has the popover code, but not the escape code.
添加它,正如koala_dev指出的那样,您应该没事:
Add it and, as koala_dev pointed out, you should be fine:
$('#example').popover();
$(document).keyup(function (event) {
if (event.which === 27) {
$('#example').popover('hide');
}
});
此外,这与模态转义函数的方式非常相似有效
这篇关于在esc按键上关闭Bootstrap popover的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文