bootstrap的模态框的使用
bootstrap的模态框
如果只想单独使用模态框功能,可以单独引入modal.js,和bootstrap的css,在bootstrap的包中,可引入bootstrap.js。
用法
通过data属性,比如设置某个butto的data-toggle=’“modal”,同时设置 data-target="#myModal" 选择器内容,
通过js直接用代码 $(’#myModal’).modal(options)
模态框主要为三部分,model-head,modeal-body,model-footer,主要内容在body中显示,class="close"为一个关闭模态框样式。
几个常用的方法 $(’#identifier’).modal(‘toggle’) 切换模态框状态
$(’#identifier’).modal(‘show’) 显示模态框
$(’#identifier’).modal(‘hide’) 隐藏模态框
事件 作用 用法
show.bs.modal 在调用 show 方法后触发。 $(’#myModal’).on(‘show.bs.modal’,function () {alert(“显示模态框”);});
shown.bs.modal 在调用 show 方法后触发。 $(’#myModal’).on(‘shown.bs.modal’, function () {alert(“完全显示模态框”); });
hide.bs.modal 在调用 hide 方法后触发。 $(’#myModal’).on(‘hide.bs.modal’, function () {alert(“隐藏模态框”);});
hidden.bs.modal 在调用 hide 方法后触发。 $(’#myModal’).on(‘hidden.bs.modal’, function () {alert(“完全隐藏模态框”); });
实例代码
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>shiro</title>
<script type="text/javascript" src="js/jquery-3.3.1.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.bootcss.com/jquery/3.4.1/core.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
var basePath = "${pageContext.request.contextPath}";
</script>
</head>
<body>
<div class="container">
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
开始演示模态框
</button>
<!-- 模态框(Modal) -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" 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="myModalLabel">
模态框(Modal)标题
</h4>
</div>
<div class="modal-body">
<div>我是模态框</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary">
提交更改
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
</div>
</body>
<script type="text/javascript">
$('#myModal').on('show.bs.modal', function () {
alert("显示模态框");
});
$('#myModal').on('shown.bs.modal', function () {
alert("完全显示模态框");
});
$('#myModal').on('hide.bs.modal', function () {
alert("隐藏模态框");
});
$('#myModal').on('hidden.bs.modal', function () {
alert("完全隐藏模态框");
});
</script>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---------------------
bootstrap的模态框的使用的更多相关文章
- Bootstrap 3 模态框播放视频
Bootstrap 3 模态框播放视频 I'm trying to use the Modal feature from Bootstrap 3 to show my Youtube video. I ...
- Bootstrap 实例 - 模态框(Modal)插件
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- bootstrap的模态框
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- Bootstrap -- 插件: 模态框、滚动监听、标签页
Bootstrap -- 插件: 模态框.滚动监听.标签页 1. 模态框(Modal): 覆盖在父窗体上的子窗体. 使用模态框: <!DOCTYPE html> <html> ...
- Bootstrap中模态框多层嵌套时滚动条问题
在使用Bootstrap中模态框过程中,如果出现多层嵌套的时候,如打开模态框A,然后在A中打开模态框B,在关闭B之后,如果A的内容比较多,滚动条会消失,而变为Body的滚动条,这是由于模态框自带的遮罩 ...
- 黄聪:bootstrap中模态框modal在苹果手机上会失效
bootstrap中模态框在苹果手机上会失效 可将代码修改为<a data-toggle="modal" data-target="#wrap" hre ...
- layui实现类似于bootstrap的模态框功能
以前习惯了bootstrap的模态框,突然换了layui,想的用layui实现类似于bootstrap的模态框功能. 用到了layui的layer模块,例如: <!DOCTYPE html> ...
- WebUploader 上传插件结合bootstrap的模态框使用时选择上传文件按钮无效问题的解决方法
由于种种原因(工作忙,要锻炼健身,要看书,要学习其他兴趣爱好,谈恋爱等),博客已经好久没有更新,为这个内心一直感觉很愧疚,今天开始决定继续更新博客,每周至少一篇,最多不限篇幅. 今天说一下,下午在工作 ...
- Bootstrap使用模态框modal实现表单提交弹出框
Bootstrap 模态框(Modal)插件 模态框(Modal)是覆盖在父窗体上的子窗体.通常,目的是显示来自一个单独的源的内容,可以在不离开父窗体的情况下有一些互动.子窗体可提供信息.交互等.如果 ...
- bootstrap删除模态框弹出并询问是否删除【通用删除模态框】
普通的询问是否删除的对话框比较low,可以利用bootstrap的模态框代替普通的对话框来实现删除. 效果: 点删除的时候弹出模态框询问是否删除,点确认的时候将需要删除的ID传到后台进行删除. 过程 ...
随机推荐
- 如何写一个bat文件,让他去执行某一个地方的bat文件
新建一个bat文件,里面编写如下内容:@echo offcall 你bat文件的路径\startup.bat pause --------------------------------------- ...
- PWA 应用
1. 使用例子,vue官网,在手机浏览器器打开时,保存在桌面那个应用.还有饿了么网站也是PWA应用.
- WIN7 下的 filemon 版本
http://blog.sina.com.cn/s/blog_594398e80100tx1q.html WIN7 下的 filemon 版本 (2011-09-26 22:26:12) 标签: fi ...
- C#后台获取根路径
C#后台获取当前系统根路径: string absoluteurl = Context.Request.Url.AbsoluteUri.Replace(Context.Request.RawUrl, ...
- 工控PLC中,关于定时器TON,TOF,的一点新认知,或者说醒悟吧!
PLC 中的定时器,都是放在一个具体PRG任务单元中的,而PRG单元需要放在具体固定的周期循环任务中才能被执行,而这个周期循环任务的循环周期 T: 与定时器的定时时间T0: T与T0 的数量级 ...
- 使用vue的extend自定义组件开发
index.js import Vue from 'vue' import tip from './tip.vue' const Constructor = Vue.extend(tip); cons ...
- python 字典(dictionary)一些方法
1.python 字典(Dictionary) keys() 函数以列表返回一个字典所有的键. keys()语法: dict.keys() 2.setdefault()方法 python字典setde ...
- VINS 回环检测与全局优化
回环检测 VINS回环检测与全局优化都在pose_graph.cpp内处理.首先在pose_graph_node加载vocabulary文件给BriefDatabase用,如果要加载地图,会loadP ...
- IE的debug工具对程序进行debug跟踪JS代码
2015/8/31 (其他的:显示zjfy_app_sys_ip.html,只需关闭启用保护模式) 显示ie的debug,F12-->Ctrl + P 扩展:第一步,在程序中设置断点,如图所示左 ...
- LLppdd likes strings
LLppdd's likes strings! Time Limit: 1 s Memory Limit: 256 MB 题目背景 LLppdd 由于实在是太弱了,在 \(ION 2018\) 模拟十 ...