jquery - 关闭 Bootstrap 模式

标签 jquery twitter-bootstrap modal-dialog

我有一个 Bootstrap 模式对话框,我想最初显示它,然后当用户单击该页面时,它就会消失。我有以下内容:

$(function () {
   $('#modal').modal(toggle)
});

 <div class="modal" id='modal'>
     <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">Error:</h3>
        </div>
        <div class="modal-body">
        <p>Please correct the following errors:</p>
        </div>
     </div>
 </div>

模态框最初显示,但在模态框外单击时不会关闭。此外,内容区域没有变灰。我怎样才能让模式最初显示,然后在用户点击区域外后关闭?以及如何让背景像演示中一样变灰?

最佳答案

modal('toggle') 替换为 modal(toggle)

$(function () {
   $('#modal').modal('toggle');
});

关于jquery - 关闭 Bootstrap 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16493280/

相关文章:

javascript - 当元素在视口(viewport)中时显示和隐藏 div

jquery-ui - jQuery-JTable:为行添加单击事件?

java - JDialog:防止父框架关闭

javascript - 单击按钮时飞入内容框?

javascript - Bootstrap 模态切换事件发生两次

jquery - 事件链接 jquery superfish

javascript - 引用错误 : $ is not defined in jQuery

html - 向上移动 bootstrap 列

html - 收缩和居中 bootstrap 3 形式

css - Bootstrap : fixed two column layout (740px content/320px sidebar)