最初に表示し、ユーザーがページをクリックすると消えるブートストラップ モーダル ダイアログ ボックスがあります。次のものがあります。
$(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>
モーダルは最初は表示されますが、モーダルの外側をクリックしても閉じません。また、コンテンツ領域はグレー表示されません。モーダルを最初に表示し、ユーザーが領域外をクリックした後に閉じるにはどうすればよいですか? また、デモのように背景をグレー表示にするにはどうすればよいですか?
ベストアンサー1
代わりmodal('toggle')
にmodal(toggle)
$(function () {
$('#modal').modal('toggle');
});