Bootstrap .modal(“ hide”)方法
Bootstrap中的.modal(“hide”)方法隐藏模式。
单击按钮即可隐藏Bootstrap模式-
$("#button1").click(function(){
$("#newModal").modal("hide");
});使用modal(“show”)方法显示模态-
$("#newModal").modal("show");让我们看一个modal('hide“)方法的例子-
示例
<!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>
<style>
#button1 {
width: 140px;
padding: 20px;
bottom: 150px;
z-index: 9999;
font-size:15px;
position: absolute;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="container">
<h2>Sample</h2>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>This is demo text.</p>
<button type="button" class="btn btn-default btn-lg" id="button1">Click to hide</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">Sample Modal</h4>
</div>
<div class="modal-body">
<p>This is demo text.</p>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$("#newModal").modal("show");
$("#button1").click(function(){
$("#newModal").modal("hide");
});
});
</script>
</body>
</html>热门推荐
10 新年祝福语独创文字简短
11 朋友弟弟生日祝福语简短
12 恭喜新郎父母简短祝福语
13 新婚红包祝福语简短男
14 简短新婚铺被子祝福语
15 收到公公生日祝福语简短
16 鼓励孩子小考祝福语简短
17 贺寿祝福语长辈简短
18 新年送老师简短祝福语