Bootstrap alert组件使用
2013-04-30 15:46
323 查看
1. 遇到的主要问题就是无法关闭弹出来的Alert提示:
<link rel="stylesheet" href="css/bootstrap.css" type="text/css"></link> <!--一定要引入JQuery ,两者具有依赖关系 注意:必须放到bootstrap.js之前--> <script src="js/jquery-1.9.1.min.js" > </script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
2.测试自动关闭的功能(设置2 S后自动关闭Alert提示Div)
<script> $(".alert-success").alert(); window.setTimeout(function() { $(".alert-success").alert('close'); }, 2000); </script>
<div class="alert alert-success fade in"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Holy guacamole!</strong> Best check yo self, you're not looking too good. </div>
3. 事件的调用(可以在关闭和关闭后进行事件的调用)
样式:<div class="alert alert-block alert-error fade in"> <button type="button" class="close" data-dismiss="alert">×</button> <h4 class="alert-heading">Oh snap! You got an error!</h4> <p>Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.</p> <p> <a class="btn btn-danger" href="#">Take this action</a> <a class="btn" id="close" data-dismiss="alert" href=".alert-block">Or do this</a> </p> </div>
Script:
<script> $(function(){ //注意:事件要绑定在UI容器上,而不是关闭按钮中 $(".alert-block").on("close",function(){ alert("这是关闭前调用的") }) $(".alert-block").on("closed",function(){ alert("这是关闭后调用的") }) }) </script>
相关文章推荐
- 如何使用Bootstrap的modal组件自定义alert,confirm和modal对话框
- 如何使用Bootstrap的modal组件自定义alert,confirm和modal对话框
- 如何使用Bootstrap的modal组件自定义alert,confirm和modal对话框
- 在rails 中,使用 simple_form 和 bootstrap 3.0 组件来美化radio button
- 在Flex中使用StyleMaager类和setStyle()方法给Alert组件设置样式
- JS组件系列——Bootstrap Select2组件使用小结
- bootstrap 的分页js组件 bootstrap-table 使用
- 使用 Bootstrap Typeahead 组件
- bootstrap框架 导航条组件使用
- 关于前端组件bootstrap使用上的几点小技巧
- Bootstrap图片轮播组件使用实例解析
- 基于Bootstrap的分页组件bootstrap-pager使用说明
- 使用Bootstrap组件【下篇】
- Alert 组件使用方法
- 使用信息提示组件 Alert
- 基于Bootstrap的标签页组件及bootstrap-tab使用说明
- BootStrap插件,组件使用注意事项
- Angular -ui - BootStrap组件的解释以及使用
- ngx-bootstrap使用04 carousel组件
- JS组件系列——Bootstrap Select2组件使用小结