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 ...
随机推荐
- ubuntu添加普通用户,并解决远程登录
创建普通用户 # 创建用户,并指定用户目录,加入用户组sudo useradd username -d /home/username -m #设置密码 sudo passwd username #给用 ...
- Web前端知识点记录
一.HTML的加载顺序 浏览器边下载HTML,边解析HTML代码,二者是从上往下同步进行的 先解析<head>中的代码,在<head>中遇到了<script>标签, ...
- SkylineGlobe 7.0.1 & 7.0.2版本Web开发 如何实现土方量计算
土方量计算,或者叫填挖方计算,体积计算,Skyline在很早的版本中就提供了这个的功能. 目前的软件版本,不仅仅可以对地形修改对象进行土方量计算,还可以在FLY工程中导入DEM数字高程模型数据,计算不 ...
- KEIL_MDK生成Bin文件
1.MDK配置 MDK是使用安装目录下的(formelf.exe)工具来生成bin文件,配置方法:勾选 "Run # 1",在后面输入框写入bin文件生成方式 2.绝对路径 &qu ...
- React-使用装饰器
create-react-app默认不支持装饰器的,需要做以下配置. 打开 package.json ,可以看到eject.运行 npm run eject 可以让由create-react-app创 ...
- 用bisect维护一个排序的序列
import bisect list1 = [] bisect.insort(list1, 5) bisect.insort(list1, 1) bisect.insort(list1, 3) bis ...
- day05(数字类型,字符串类型,列表类型)
一,复习: 1.顺序结构.分支结构.循环结构 2.if分支结构 if 条件: 代码块 elif 条件: 代码块 else: 代码块 # 可以被if转换为False:0 | '' | None | [] ...
- Neutron :默认通过 dnsmasq 实现 DHCP 功能----Namespace
Neutron 提供 DHCP 服务的组件是 DHCP agent. DHCP agent 在网络节点运行上,默认通过 dnsmasq 实现 DHCP 功能. 配置 DHCP agent DHCP ...
- python中打印中文
python中打印中文 在python 2.x版本中,默认是ASCII编码方式,在有业务需要输入中文时,就会出现乱码的情况.解决这种问题的一个方式就是设置py文件的编码方式.实现方式如下: 在py文件 ...
- mybatis 使用resultMap实现表间关联
AutoMapping auto mapping,直译过来就是自动映射,工作原理大概如下: 假设我们有一张表,表名为person,包含id,name,age,addr这4个字段 mysql> d ...