<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>模态框</title>
<link rel="stylesheet" type="text/css"
href="bootstrap/css/bootstrap.min.css"/>
<script src="js/jquery-3.4.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<!--
1.通过data属性:
在控制器元素(比如按钮或链接)上设置属性data-toggle="modal",
同时设置data-target="#identifier" 或 href="#identifier",
来指定要切换的特定的模态框
2.通过Javasrcipt:
使用这种技术,可以通过Javascript来调用带有id="identifier"的
模态框
打开模态框:$('#identifier').modal('show')
关闭模态框:$('#identifier').modal('hide')
-->
<!--通过 data 属性-->
<button class="btn btn-primary" data-toggle="modal" data-target="#modal_01">打开模态框</button>
<!--通过Javascript-->
<button class="btn btn-primary" id="btn_01">打开模态框</button>
<!--模态框Modal-->
<div class="modal fade" id="modal_01" tabindex="-1" role="dialog" aria-labelledby="modal_01_label"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="modal_01_label">
添加用户
</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="uname" class="col-md-2 control-label">姓名</label>
<div class="col-md-8">
<input type="text" id="uname" class="form-control" placeholder="请输入姓名"/>
</div>
</div>
<div class="form-group">
<label for="upwd" class="col-md-2 control-label">密码</label>
<div class="col-md-8">
<input type="password" id="upwd" class="form-control" placeholder="请输入密码"/>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary" id="submit_btn">提交更改</button>
</div>
</div>
</div>
</div>
<script>
// 绑定按钮的点击事件
$("#btn_01").click(function(){
//手动打开模态框
$("#modal_01").modal("show");
});
//关闭模态框
$("#submit_btn").click(function(){
$("#modal_01").modal("hide");
});
</script>
</body>
</html>
网站首页 > 编程文章 正文
猜你喜欢
- 2024-08-17 扩散登录表单动画(超级表单登录)
- 2024-08-17 jQuery 事件(jquery 事件代理)
- 2024-08-17 【Chrome】浏览器Console引入Jquery
- 2024-08-17 js 实现代码复制(js复制文本代码)
- 2024-08-17 Ajax跨域问题详解(ajax实现跨域三种方法)
- 2024-08-17 html高级教程canvas操作,简单易学
- 2024-08-17 jQuery 获取和设置HTML元素(jquery获取元素的html)
- 2024-08-17 jQuery实现简易购物车功能(jsp实现简单购物车)
- 2024-08-17 用 Bootstrap4 制作响应式网页二(导航菜单)
- 2024-08-17 jquery放大镜(一)(放大镜html)
你 发表评论:
欢迎- 05-16时尚芭莎90秒|有理有据!冬装购买选色指南
- 05-16VS code使用入门(1)
- 05-16Git基本使用,分布式版本控制
- 05-16从某宝奸商淘回来的惠普ELITEBOOK 8570P,全金属好机
- 05-16Qt中添加OpenCV库
- 05-16cygwin安装skyeye所需的软件包列表
- 05-16code::blocks安装及汉化完整教程
- 05-16人人可以做程序员,CurSor编程神器!
- 最近发表
- 标签列表
-
- spire.doc (59)
- system.data.oracleclient (61)
- 按键小精灵源码提取 (66)
- pyqt5designer教程 (65)
- 联想刷bios工具 (66)
- c#源码 (64)
- graphics.h头文件 (62)
- mysqldump下载 (66)
- sqljdbc4.jar下载 (56)
- libmp3lame (60)
- maven3.3.9 (63)
- 二调符号库 (57)
- 苹果ios字体下载 (56)
- git.exe下载 (68)
- diskgenius_winpe (72)
- pythoncrc16 (57)
- solidworks宏文件下载 (59)
- qt帮助文档中文版 (73)
- satacontroller (66)
- hgcad (64)
- bootimg.exe (69)
- android-gif-drawable (62)
- axure9元件库免费下载 (57)
- libmysqlclient.so.18 (58)
- springbootdemo (64)
本文暂时没有评论,来添加一个吧(●'◡'●)