toastr jQuery消息通知插件文档

简介

Toastr是一款基于jQuery的通知插件,可以灵活的自定义样式和拓展其功能!

项目Github主页:https://github.com/CodeSeven/toastr

引用

<span style="font-family:Comic Sans MS;"><link href="toastr.css" rel="stylesheet"/>
<script src="jquery.js"></script>
<script src="toastr.js"></script></span>

使用

//显示一个没有标题的信息框(蓝色)
toastr.info("I am yanying");

//显示一个没有标题的警告框(橘黄色)
toastr.warning("I am yanying");

//显示一个没有标题的成功提示(绿色)
toastr.info("I am yanying");

//显示一个没有标题的错误提示(深红色)
toastr.error("I am yanying");

//清除一个错误
toastr.clear()</span>
高级方法

使用这种方法也可以调用通知插件,而且还可以配置一些参数信息,达到不同功能和效果

$(function () {

        $('#showtoast').click(function () {

            toastr.options = {

                closeButton: false,
                debug: false,
                progressBar: false,
                positionClass: "toast-top-right",
                onclick: null,
                showDuration: "300",
                hideDuration: "1000",
                timeOut: "5000",
                extendedTimeOut: "1000",
                showEasing: "swing",
                hideEasing: "linear",
                showMethod: "fadeIn",
                hideMethod: "fadeOut"
            };

            var $toast = toastr['error']('123', 'title');

        });

    })

可供选择的设置选项

closeButton: true

是否在通知弹窗上面显示关闭按钮,true:显示;false:不显示


debug: true

是否开起debug


progressBar: false

是否显示进度条,当为false时候不显示;当为true时候,显示进度条,当进度条缩短到0时候,消息通知弹窗消失


positionClass: 'toast-top-right'

位置信息,消息弹窗显示的位置,可以显示的位置对应的值

  1. toast-top-right
  2. toast-botton-right
  3. toash-bottom-left
  4. toast-top-left
  5. toast-top-full-width 这个是在网页顶端,宽度铺满整个屏幕
  6. toast-bottom-full-width
  7. toast-top-center顶端中间
  8. toast-bottom-center
onclick: null

showDuration: "300"

显示动作(从无到有这个动作)持续的时间


hideDuration: "1000"

隐藏动作持续的时间


timeOut: "5000"

间隔的时间


extendedTimeOut: "1000"

showEasing: "swing",
hideEasing: "linear",
showMethod: "fadeIn"

显示的方式,和jquery相同,可以是show()


hideMethod: "fadeOut"

隐藏的方式,和jquery相同,可以是hide()


toastr['error']('I am yanying', 'title');

其中的error为显示的通知的样式类型,有4种选择

  1. success 成功,绿色
  2. info 信息,蓝色
  3. warning,警告,橙色
  4. error,错误,深红色
其中第一个参数为显示的内容,第二个参数为显示的标题,标题可以省略


  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
jQuery插件raty是一个用于创建星级评分的工具。以下是raty中文文档的使用说明: 1. 引入raty.js文件和jquery.js文件: ```html <script src="jquery.js"></script> <script src="raty.js"></script> ``` 2. 创建一个元素来显示评分: ```html <div id="star"></div> ``` 3. 通过JavaScript代码来初始化评分: ```javascript $('#star').raty({ path: 'images/', // 图片文件的路径 score: 3, // 初始化评分 click: function(score, event) { // 点击评分时的回调函数 alert('您给了 ' + score + ' 分'); } }); ``` 以上代码中,`path`属性指定了图片文件的路径,`score`属性指定了初始化评分,`click`回调函数在评分被点击时被调用。 4. 可以使用其他选项来自定义raty的外观和行为,例如: ```javascript $('#star').raty({ path: 'images/', starOn: 'star-on.png', // 选中时的星星图片 starOff: 'star-off.png', // 未选中时的星星图片 starHalf: 'star-half.png', // 半选中时的星星图片 half: true, // 允许半选中 readOnly: true, // 只读模式 hints: ['差', '一般', '好', '很好', '非常好'], // 显示提示文本 score: function() { // 动态获取评分 return $(this).attr('data-score'); }, click: function(score, event) { alert('您给了 ' + score + ' 分'); } }); ``` 以上代码中,`starOn`、`starOff`和`starHalf`属性指定了不同状态下的星星图片,`half`属性允许半选中,`readOnly`属性设置为`true`表示只读模式,`hints`属性用于显示提示文本,`score`属性可以用函数来动态获取评分。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值