zoukankan      html  css  js  c++  java
  • Jquery消息提示插件toastr使用详解

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

     

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

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

    html

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

    2、效果 


    这里写图片描述

    3、集成使用

    复制代码
     1 //常规消息提示,默认背景为浅蓝色  
     toastr.info("你有新消息了!");  
    2 //成功消息提示,默认背景为浅绿色 toastr.success("你有新消息了!");
    3 //警告消息提示,默认背景为橘黄色 toastr.warning("你有新消息了!");
    4 //错误消息提示,默认背景为浅红色 toastr.error("你有新消息了!");
    5 //带标题的消息框 toastr.success("你有新消息了!","消息提示");
    6 //另一种调用方法 toastr["info"]("你有新消息了!","消息提示");
    复制代码

     

    4、自定义用法 

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

    自定义参数: 
    JavaScript

    复制代码
     1 toastr.options = {  
     2         closeButton: false,  
     3         debug: false,  
     4         progressBar: true,  
     5         positionClass: "toast-bottom-center",  
     6         onclick: null,  
     7         showDuration: "300",  
     8         hideDuration: "1000",  
     9         timeOut: "2000",  
    10         extendedTimeOut: "1000",  
    11         showEasing: "swing",  
    12         hideEasing: "linear",  
    13         showMethod: "fadeIn",  
    14         hideMethod: "fadeOut"  
    15     };  
    复制代码

    参数说明: 
    closeButton:false,是否显示关闭按钮(提示框右上角关闭按钮); 
    debug:false,是否为调试; 
    progressBar:false,是否显示进度条(设置关闭的超时时间进度条); 
    positionClass,消息框在页面显示的位置

    复制代码
    1 toast-top-left  顶端左边
    2 toast-top-right    顶端右边
    3 toast-top-center  顶端中间
    4 toast-top-full-width 顶端,宽度铺满整个屏幕
    5 toast-botton-right  
    6 toast-bottom-left
    7 toast-bottom-center
    8 toast-bottom-full-width
    复制代码
    复制代码
    1 onclick,点击消息框自定义事件 
    2 showDuration: “300”,显示动作时间 
    3 hideDuration: “1000”,隐藏动作时间 
    4 timeOut: “2000”,自动关闭超时时间 
    5 extendedTimeOut: “1000” 
    6 showEasing: “swing”, 
    7 hideEasing: “linear”, 
    8 showMethod: “fadeIn” 显示的方式,和jquery相同 
    9 hideMethod: “fadeOut” 隐藏的方式,和jquery相同
    复制代码
  • 相关阅读:
    Sicily 1795 Table tennis
    【转】关于使用printf和scanf对short进行输入输出的一段有趣对话
    Sicily 1561 PRIME
    【读书笔记】the TeXBook 1
    Sicily 1934 移动小球
    Sicily 1817 校歌手大奖赛
    个人总结flex各种用法(转)
    ActionScript3编译运行
    Flash & Flex组件优化的杀手锏callLater
    readResolve()方法与串行化
  • 原文地址:https://www.cnblogs.com/lq-93/p/9989302.html
Copyright © 2011-2022 走看看