jQuery提示组件toastr(取代alert)
给大家推荐一款jquery提示插件:toastr
它是一个可以取代alert的提示信息框,它在PC,移动设备上都有不错的UI效果。
具体使用方法如下:
1、首先在网页头站调用他需要的js和css文件。
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script>
<link href="https://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
2、然后就可以自定义该组件的相关参数和事件了。
比如弹出的位置,大小,配色,类型等等。
<script type="text/javascript">
//美化版彈窗
$(function(){
var messageOpts = {
"closeButton": false,
"debug": false,
"positionClass": "toast-top-right",
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
toastr.options = messageOpts;
$('#showtoast').click(function() {
//提示
//调用方法1
toastr.info('内容1');
//调用方法2
//toastr.info('内容2', '标题2');
//调用方法3
//toastr['info']('内容3', '标题3');
//调用方法4
//toastr.info('内容4', '标题4',messageOpts);
}); $('#showtoastsuccess').click(function() {
//成功
toastr.success('内容success', '标题success');
}); $('#showtoasterror').click(function() {
//错误
toastr.error('内容error', '标题error');
}); $('#showtoastwarning').click(function() {
//警告
toastr.warning('内容warning', '标题warning');
});
}) </script>
3、HTML中调用相关事件:
<button id="showtoast">show info toast(提示)</button>
<br>
<button id="showtoastsuccess">show success toast(成功)</button>
<br>
<button id="showtoasterror">show error toast(错误)</button>
<br>
<button id="showtoastwarning">show warning toast(警告)</button>
该插件完整演示页:
http://www.shouce.ren/api/jq/5733e3732c588/index.html
懒人党福利,完整代码直接测试:
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script>
<link href="https://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css" rel="stylesheet"> <script type="text/javascript">
//美化版彈窗
$(function(){
var messageOpts = {
"closeButton": false,
"debug": false,
"positionClass": "toast-top-right",
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
toastr.options = messageOpts;
$('#showtoast').click(function() { //提示
//调用方法1
toastr.info('内容1');
//调用方法2
//toastr.info('内容2', '标题2');
//调用方法3
//toastr['info']('内容3', '标题3');
//调用方法4
//toastr.info('内容4', '标题4',messageOpts);
}); $('#showtoastsuccess').click(function() {
//成功
toastr.success('内容success', '标题success');
}); $('#showtoasterror').click(function() {
//错误
toastr.error('内容error', '标题error');
});
$('#showtoastwarning').click(function() {
//警告
toastr.warning('内容warning', '标题warning');
});
}) </script>
</head> <body>
<button id="showtoast">show info toast(提示)</button>
<br>
<button id="showtoastsuccess">show success toast(成功)</button>
<br>
<button id="showtoasterror">show error toast(错误)</button>
<br>
<button id="showtoastwarning">show warning toast(警告)</button>
</body>
</html>
jQuery提示组件toastr(取代alert)的更多相关文章
- 漂亮灵活设置的jquery通知提示插件toastr
toastr是一款非常棒的基于jquery库的非阻塞通知提示插件,toastr可设定四种通知模式:成功,出错,警告,提示,而提示窗口的位置,动画效果都可以通过能数来设置,在官方站可以通过勾选参数来生成 ...
- Web jquery表格组件 JQGrid 的使用 - 5.Pager翻页、搜索、格式化、自定义按钮
系列索引 Web jquery表格组件 JQGrid 的使用 - 从入门到精通 开篇及索引 Web jquery表格组件 JQGrid 的使用 - 4.JQGrid参数.ColModel API.事件 ...
- Web jquery表格组件 JQGrid 的使用 - 11.问题研究
系列索引 Web jquery表格组件 JQGrid 的使用 - 从入门到精通 开篇及索引 Web jquery表格组件 JQGrid 的使用 - 4.JQGrid参数.ColModel API.事件 ...
- Web jquery表格组件 JQGrid 的使用 - 4.JQGrid参数、ColModel API、事件及方法
系列索引 Web jquery表格组件 JQGrid 的使用 - 从入门到精通 开篇及索引 Web jquery表格组件 JQGrid 的使用 - 4.JQGrid参数.ColModel API.事件 ...
- Web jquery表格组件 JQGrid 的使用 - 7.查询数据、编辑数据、删除数据
系列索引 Web jquery表格组件 JQGrid 的使用 - 从入门到精通 开篇及索引 Web jquery表格组件 JQGrid 的使用 - 4.JQGrid参数.ColModel API.事件 ...
- Web jquery表格组件 JQGrid 的使用 - 8.Pager、新增数据、查询、刷新、查看数据
系列索引 Web jquery表格组件 JQGrid 的使用 - 从入门到精通 开篇及索引 Web jquery表格组件 JQGrid 的使用 - 4.JQGrid参数.ColModel API.事件 ...
- Web jquery表格组件 JQGrid 的使用 - 全部代码
系列索引 Web jquery表格组件 JQGrid 的使用 - 从入门到精通 开篇及索引 Web jquery表格组件 JQGrid 的使用 - 4.JQGrid参数.ColModel API.事件 ...
- [js开源组件开发]tip提示组件
tip提示组件 常见的应用场景中,总是难免会遇到提示信息,比如显示不完全时需要鼠标移上去显示title,比如验证时的错误提示,比如操作按钮的辅助说明等,所以我独立出来了一个小的js组件,tip提示组件 ...
- 【ASP.Net MVC】在AspNet Mvc使用JQuery AutoComplete组件
在AspNet Mvc使用JQuery AutoComplete组件 官方文档: http://api.jqueryui.com/autocomplete/#entry-examples 要使用JQu ...
随机推荐
- Loj #2324. 「清华集训 2017」小 Y 和二叉树
Loj #2324. 「清华集训 2017」小 Y 和二叉树 小Y是一个心灵手巧的OIer,她有许多二叉树模型. 小Y的二叉树模型中,每个结点都具有一个编号,小Y把她最喜欢的一个二叉树模型挂在了墙上, ...
- 模拟vue的tag属性,在react里实现自定义Link
我封装了一个简单的实现react里自定义Link的方法,方便大家使用. 因为普通组件没有metch.location.history等属性.只有在<Router>里面的<compon ...
- Docker 安装 MySQL
1. docker search mysql 2.docker pull mysql/mysql-serer 3.mkdir -p ~/mysql/data ~/mysql/logs ~/mysql/ ...
- 【Git】+ 新建+删除+上传+覆盖
上传代码时邮箱格式不符合:https://blog.csdn.net/u012558695/article/details/64921922 在本地新建一个分支: git branch newBran ...
- P1273 有线电视网
题目描述 某收费有线电视网计划转播一场重要的足球比赛.他们的转播网和用户终端构成一棵树状结构,这棵树的根结点位于足球比赛的现场,树叶为各个用户终端,其他中转站为该树的内部节点. 从转播站到转播站以及从 ...
- Linux配置外网访问mysql
stream{ upstream abc{ server 192.168.8.249:3306; } server{ listen 9211 ; prox ...
- python scapy dns 包字段解析
qr: 0表示查询报文,1表示响应报文opcode: 通常值为0(标准查询),其他值为1(反向查询)和2(服务器状态请求).aa: 表示授权回答(authoritative answer)tc: ...
- C#中字符串的字面值(转义序列)
在程序开发中,经常会碰到在字符串中字面值中使用转义序列,下面表格收集了下转义序列的完整列表,以便大家查看引用: 转义序列列表 转义序列 产生的字符 字符的Unicode值 \' 单引号 0x0027 ...
- DAO 四个包的建立
一.DAO 四个包的建立,降低代码之间的耦合性? 之前写代码,都是在一个包下.代码耦合性较高,不利于后期的维护. dao(代码分层?) 有利于后期的维护代码,修改方便. com.aaa.dao 存放d ...
- BZOJ4643 卡常大水题 【Tarjan】
题目分析: 给所有边按A排序,依次加入再按B递增排序,势能分析可以发现是O(n^4)的 代码: #include<bits/stdc++.h> using namespace std; ; ...