我要提交此模式表格。在stackoverflow中搜索后,在jQuery中找到了将其关闭的代码,但对我不起作用!此jquery代码位于 index.html
中$(document).ready(function(){
$(".modal :button").click(function(){
$('.modal').modal('hide');
});
});
这根本不绑定到那些.modal和Submit按钮。 还尝试从按钮的ID绑定单击事件,但无法再次使用
答案 0 :(得分:0)
如果您按照代码指示使用引导程序,则只需将data-dismiss =“ modal”属性添加到模式中的按钮,它将在单击时关闭模式。
例如:
<button type="button" class="btn btn-default pull-right" data-dismiss="modal">Close</button>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src=" https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<button type="button" data-toggle="modal" data-target="#demo-modal" class="btn btn-default">Click to show modal</button>
<div id="demo-modal" class="modal fade">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close pull-right" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4>Modal header</h4>
</div>
<div class="modal-body clearfix">
<p>Modal body</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-right" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>