关闭引导模式 [英] Close Bootstrap Modal

查看:23
本文介绍了关闭引导模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a bootstrap modal dialog box that I want to show initially, then when the user clicks on the page, it disappears. I have the following:

$(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>

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

The modal is displayed initially, but it does not close when clicked outside of the modal. Also, the content area is not greyed out.. How can I get the modal to display initially, then close after the user clicks outside the area? And how can I get the background to be grayed out as in the demo?

推荐答案

modal('toggle') 代替 modal(toggle)

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

这篇关于关闭引导模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆