实现功能:
完整代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>模态框(Modal)插件</title>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<!-- 按钮触发模态框 -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#modal">
打开模态框
</button>
<!-- 模态框内容 -->
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modalLabel">
模态框标题
</h4>
</div>
<div class="modal-body">
内容
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">
按钮
</button>
</div>
</div><
</div>
<script type="text/javascript">
//js里调用show函数,控制打开模态框
function show() {
$('#modal').modal('show');
}
//js里调用close函数,控制关闭模态框
function hide() {
$('#modal').modal('hide');
}
</script>
</div>
</body>
</html>
ConstXiong 备案号:苏ICP备16009629号-3