Bootstrap警告框(Alert)插件使用方法
作者:boonyaxnn 时间:2024-04-27 15:23:05
有以下两种方式启用警告框的可取消(dismissal)功能:
1、通过 data 属性:通过数据 API(Data API)添加可取消功能,只需要向关闭按钮添加 data-dismiss="alert",就会自动为警告框添加关闭功能。
<a class="close" data-dismiss="alert" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" aria-hidden="true">×</a>
2、通过 JavaScript添加可取消功能:
$(".alert").alert()
html代码
<div class="alert alert-success">
<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="close" data-dismiss="alert" aria-hidden="true">√</a>
<strong>成功!</strong>您的网络连接已成功!
</div>
效果图:
3、下面是一些警告框(Alert)插件中有用的方法:
效果图
4、下表列出了警告框(Alert)插件中要用到的事件。这些事件可在函数中当钩子使用。
html代码
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 警告框(Alert)插件</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/bootstrap.min.css" rel="external nofollow" >
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<style>
body{
font-size:24px;
}
</style>
</head>
<body>
<div class="container">
<h3>警告框(Alert)插件 alert() 方法</h3>
<div id="myAlert" class="alert alert-warning">
<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="close" data-dismiss="alert">×</a>
<strong>警告!</strong>您的网络连接有问题。
</div>
<script type="text/javascript">
$(function() {
$("div#myAlert").bind('click',function () {
alert("警告消息框被关闭。");
});
});
</script>
</div>
</body>
</html>
效果图:
标签:Bootstrap,警告框,Alert
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
SQL语句中LEFT JOIN的ON和WHERE有什么区别
2024-01-21 04:33:00
![](https://img.aspxhome.com/file/2023/9/115549_0s.png)
Python使用scrapy采集时伪装成HTTP/1.1的方法
2023-07-07 01:28:40
python实现超级玛丽游戏
2023-10-02 20:19:28
![](https://img.aspxhome.com/file/2023/9/99299_0s.gif)
python时间日期操作方法实例小结
2021-03-13 11:01:45
详解Python requests模块
2021-12-31 21:55:12
Django权限控制的使用
2023-12-27 01:50:57
![](https://img.aspxhome.com/file/2023/9/85269_0s.png)
解决Python pandas df 写入excel 出现的问题
2021-07-27 15:37:21
![](https://img.aspxhome.com/file/2023/6/117626_0s.jpg)
mysql如何通过my.ini更改默认字符集
2024-01-28 08:25:07
![](https://img.aspxhome.com/file/2023/4/115274_0s.jpg)
快速掌握怎样选择准备安装的 MySQL版本
2008-12-17 16:42:00
Python Pandas 对列/行进行选择,增加,删除操作
2022-10-29 03:55:52
基于PyQT5制作英雄联盟全皮肤下载器
2023-07-03 15:54:08
![](https://img.aspxhome.com/file/2023/2/134442_0s.png)
PHP用mysql数据库存储session的代码
2023-09-05 00:44:50
Div+CSS布局入门教程
2007-09-13 12:52:00
![](https://img.aspxhome.com/file/uploadpic/20079/13/20079131325394.gif)
Oracle11.2 命令行手工最简创建数据库的过程
2009-09-14 12:07:00
python统计字符串中指定字符出现次数的方法
2022-11-17 11:37:46
Python语言进阶知识点总结
2022-11-09 01:21:37
![](https://img.aspxhome.com/file/2023/5/101445_0s.png)
Python3实现飞机大战游戏
2022-08-25 05:29:03
![](https://img.aspxhome.com/file/2023/6/81826_0s.jpg)
Python正则抓取新闻标题和链接的方法示例
2022-05-16 06:01:31
Python使用Phantomjs截屏网页的方法
2022-06-17 15:47:14
Python大数据量文本文件高效解析方案代码实现全过程
2023-01-18 04:57:01