关闭 Bootstrap 模态 [英] Close Bootstrap Modal

查看:37
本文介绍了关闭 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">错误:</h3>

<div class="modal-body"><p>请更正以下错误:</p>

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

解决方案

Put modal('toggle') 而不是 modal(toggle)

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

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?

解决方案

Put modal('toggle') instead of modal(toggle)

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

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

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆