我有一个 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/