模态完全显示时的Bootstrap事件
完全显示模式后,Bootstrap中的shown.bs.modal事件就会触发。
使用modal(show)方法显示模态-
$("#button1").click(function(){
$("#newModal").modal("show");
});触发show.bs.modal事件并生成警报,如下所示-
$("#newModal").on('shown.bs.modal', function () {
alert('The modal is displayed completely!');
});您可以尝试运行以下代码以在Bootstrap中实现show.bs.modal事件-
示例
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Entrance Exams</h2>
<p>The following is the result of the entrance exams:</p>
<button type="button" class="btn btn-default btn-lg" id="button1">Result</button>
<div class="modal fade" id="newModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Selected Students</h4>
</div>
<div class="modal-body">
<p>Rahul, Amit and Shweta cleared the exam.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$("#button1").click(function(){
$("#newModal").modal("show");
});
$("#newModal").on('shown.bs.modal', function () {
alert('The modal is displayed completely!');
});
});
</script>
</body>
</html>热门推荐
1 如何训练狗狗不叫
2 训练狗狗不叫
3 训练狗狗随行
4 怎么训练狗狗不叫
7 训练比熊狗狗教程
10 上海狗狗训练
11 怎么训练狗狗上厕所
12 训练狗狗趴下
13 狗狗服从训练
14 训练狗狗拒食
15 训练狗狗笑
16 训练狗狗大便
17 训练狗狗立
18 训练狗狗捡东西