bootstrap里的弹框组件Model
来源:互联网 发布:淘宝抢购提醒查看 编辑:程序博客网 时间:2024/06/06 01:00
首先,你得引入对应的包:
<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
接着创建一个提供出发弹框的标签:
<span class="btn btn-primary btn-lg" data-toggle="modal" data-target="#ww">
点我
</span>
这里的标签也可用<button></button>
再接着就是创建弹框:
<!-- 模态框(Modal) -->
<div class="modal fade" id="." tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">
标题
</h4>
</div>
<div class="modal-body">
内容
</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>
值得提醒的是,span 标签或者是你的button标,这个data-toggle="modal"属性用来把 <div> 的内容识别为模态框;里面的data-target属性的值,就是你创建弹出框的id的值 ,这个是要保持一致的;关于.fade样式是用来让模态窗被切换会有淡入淡出的效果;aria-labelledby属性用来确定引入该模板的标题;aria-hidden="true" 用于保持模态窗口不可见,直到触发器被触发为止(比如点击在相关的按钮上);
另外如果想要单独引用该插件的功能,那么您需要引用 modal.js。或者,可以引用 bootstrap.js 或压缩版的 bootstrap.min.js。
用jquery创建:
<script>$(function() {
$('#myModal').modal('hide');//hide和show控制model的隐藏和显示,其中toogle也是可以用的
});
// $('#myModal').on('hidden', function () {// do something…});
</script>
其中关闭按钮事件:
$(function () { $('#myModal').on('hide.bs.modal', function () {
alert('点击的是关闭按钮');})
});
注意:show.bs.model,相当于模态框对用户可见时触发,
hide.bs.model,相当于触发了hide事件,即为隐藏。
- bootstrap里的弹框组件Model
- bootstrap model弹出框的使用
- bootstrap model弹出框的使用
- bootstrap model弹出框的使用
- bootstrap 模态框model的使用
- BootStrap的导航组件
- bootstrap的那些组件
- bootstrap的组件
- bootstrap警告框组件
- bootstrap里bootstrap动态加载下拉框
- bootstrap中弹出层model的用法
- bootstrap 中model弹出窗的使用
- Bootstrap里的文件作用
- Bootstrap里的文件作用
- bootstrap表单的其他组件
- Bootstrap Typeahead 组件的使用
- bootstrap表单的其他组件
- Bootstrap组件之警告框
- java replace和replaceAll的区别以及用法
- OC runtime 类与对象
- 大数据教程(三) Hadoop集群分布式坏境搭建
- jmeter学习笔记(三)-性能测试概念
- 获取表单 input框中输入的值
- bootstrap里的弹框组件Model
- The tidy tools manifesto
- 解决“要登录到这台远程计算机,你必须被授予“的远程无法登陆问题
- DES算法原理
- Android新建文件夹的步骤
- 【iOS_Development】文件操作
- 在安卓手机中读写文件基本方法
- Java 注解
- Java DOM4J 方式解析XML文件