Jquery消息提示插件toastr使用详解

toastr是一个基于Jquery简单、漂亮的消息提示插件,使用简单、方便,可以根据设置的超时时间自动消失。

1、使用很简单,首选引入toastr的js、css文件
html

<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="<%=path%>/res/toastr/toastr.min.js"></script>
<link rel="stylesheet" href="<%=path%>/res/toastr/toastr.min.css">


2、效果


3、集成使用

//常规消息提示,默认背景为浅蓝色  
toastr.info("你有新消息了!");  
//成功消息提示,默认背景为浅绿色 
toastr.success("你有新消息了!")
//警告消息提示,默认背景为橘黄色 
toastr.warning("你有新消息了!");  
//错误消息提示,默认背景为浅红色 
toastr.error("你有新消息了!");  
//带标题的消息框
toastr.success("你有新消息了!","消息提示");  


4、自定义用法
通过设置自定义参数,可达到不同的效果

自定义参数:
javascript

                toastr.options = {  //消息提示框的一些参数
                    "closeButton": true,  // 是否显示关闭按钮,(提示框右上角关闭按钮)
                    "debug": false,         // 是否使用deBug模式
                    "progressBar": true,     // 是否显示进度条,(设置关闭的超时时间进度条)
                    "positionClass": "toast-top-center",  // 设置提示款显示的位置
                    "onclick": null,        // 点击消息框自定义事件
                    "showDuration": "400",  // 显示动画的时间
                    "hideDuration": "1000", // 消失的动画时间
                    "timeOut": "7000",      // 自动关闭超时时间
                    "extendedTimeOut": "1000", // 加长展示时间
                    "showEasing": "swing",  // 显示时的动画缓冲方式
                    "hideEasing": "linear", // 消失时的动画缓冲方式
                    "showMethod": "fadeIn",  // 显示时的动画方式
                    "hideMethod": "fadeOut"  // 消失时的动画方式
                }


参数说明:
positionClass

toast-top-left  顶端左边
toast-top-right    顶端右边
toast-top-center  顶端中间
toast-top-full-width 顶端,宽度铺满整个屏幕
toast-botton-right  
toast-bottom-left
toast-bottom-center
toast-bottom-full-width

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值