我正在尝试编写一段代码,使您能够在按下回车键后关闭打开的 Bootstrap 模式。
这是我的代码:
$(document).keyup(function(e) {
if(e.keyCode==13){
if(!$(e.target).closest('.modal fade in').length) {
$('.modal').each(function(){
$(this.previousSibling).modal('hide');
});
}
}
});
请帮忙,我做错了什么?
最佳答案
我做的很简单:
$('.modal').modal('hide');
并且所有打开的模态都关闭。
什么鬼啊! :D
关于javascript - 按下回车键时 Bootstrap 模式关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21804606/