javascript - 按下回车键时 Bootstrap 模式关闭

标签 javascript jquery twitter-bootstrap

我正在尝试编写一段代码,使您能够在按下回车键后关闭打开的 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/

相关文章:

html - 宽度 : 100%; making images on desktop bigger than original size

css - 相对体内的绝对位置不起作用

javascript - 如何在php中获取并打印页面内的图像

javascript - 在 div 单击时运行 javascript?

javascript - 带有 JSONP 的 AJAX 返回错误 Callback is Undefined

javascript - 使用 $(this) 和 jQuery 访问内部文本

javascript - jQuery CSS 位置不工作

javascript - 在 javascript 或 bootstrap 中创建可点击的工具提示

javascript - Node - 在继续之前等待 map 完成

javascript - 如何从子类调用父类(super class)中的 getter/setter?