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 ...
随机推荐
- web框架开发-Django简介
MVC与MTV模型 MVC Web服务器开发领域里著名的MVC模式,所谓MVC就是把Web应用分为模型(M),控制器(C)和视图(V)三层,他们之间以一种插件式的.松耦合的方式连接在一起,模型负责业务 ...
- Go语言中定时器cron的基本使用
安装:go get github.com/robfig/cron 如果出不去就用gopm 例子: package main import ( "fmt" "github ...
- 做自己的docker镜像(基于ubuntu:16.04)
基于ubuntu:16.04 apt-get update -y apt-get install sudo -y 换源 sudo apt-get install vim sudo vim /etc/a ...
- [LeetCode] 16. 最接近的三数之和
题目链接:https://leetcode-cn.com/problems/3sum-closest/ 题目描述: 给定一个包括 n 个整数的数组 nums 和 一个目标值 target.找出 num ...
- c++ cout、cin、endl
cout是标准输出流对象,<<是输出操作符:cin是标准输入流对象,>>是输入操作符:endl是换行符操作符.他们都属于C++标准库,所以都在std的名字空间里.所以要在开头写 ...
- PS制作简洁漂亮的立体抽丝文字
一.新建一个800*600px文档,并将Background图层创建一个副本,将其命名为Background_copy. 二.双击Background_copy图层,勾选渐变叠加,并设定以下数值 勾选 ...
- 让多个HTML页面 使用 同一段HTML代码
需求背景 一个网站有多个网页:一个网页,可以分为很多部分,举个例子,下面是一个特别简单的网页结构: 一般情况下,footer都是用于标识网站的相关信息(备案.联系方式.制作方),每一个页面都是相 ...
- xadmin在Django 1.11中的使用及中英文切换
版权声明:本文为博主原创文章,欢迎转载,并请注明出处.联系方式:460356155@qq.com xadmin是一个强大的替代django admin的管理后台,github地址为:https://g ...
- 采用VSPD、ModbusTool模拟串口、MODBUS TCP设备进行Python采集软件开发
版权声明:本文为博主原创文章,欢迎转载,并请注明出处.联系方式:460356155@qq.com 不少仪器/设备都提供了数据采集的接口,其中不少是串口或网络的MODBUS/TCP协议. 串口是比较简单 ...
- Linux 学习 (十) 网络配置
Linux网络管理 学习笔记 配置 IP 地址 ifconfig 命令临时配置 IP 地址 ifconfig eth0 192.168.0.200 netmask 255.255.255.0 #临时设 ...