jquery插件jquery倒計時插件分享_jquery
來源:懂視網
責編:小采
時間:2020-11-27 21:17:51
jquery插件jquery倒計時插件分享_jquery
jquery插件jquery倒計時插件分享_jquery: 代碼如下:$(document).ready(function () { /* 延遲函數 */ jQuery.fn.delay = function (time, func) { return this.each(function () { setTimeout(func, time); }); }; jQuery.fn.countDown = f
導讀jquery插件jquery倒計時插件分享_jquery: 代碼如下:$(document).ready(function () { /* 延遲函數 */ jQuery.fn.delay = function (time, func) { return this.each(function () { setTimeout(func, time); }); }; jQuery.fn.countDown = f

代碼如下:
$(document).ready(function () {
/* 延遲函數 */
jQuery.fn.delay = function (time, func) {
return this.each(function () {
setTimeout(func, time);
});
};
jQuery.fn.countDown = function (settings, to) {
settings = jQuery.extend({
startFontSize: '36px',
endFontSize: '12px',
duration: 1000,
startNumber: 10,
endNumber: 0,
callBack: function () { }
}, settings);
return this.each(function () {
if (!to && to != settings.endNumber) { to = settings.startNumber; }
//設定倒計時開始的號碼
$(this).text(to).css('fontSize', settings.startFontSize);
//頁面動畫
$(this).animate({
'fontSize': settings.endFontSize
}, settings.duration, '', function () {
if (to > settings.endNumber + 1) {
$(this).css('fontSize', settings.startFontSize).text(to - 1).countDown(settings, to - 1);
}
else {
settings.callBack(this);
}
});
});
};
//使用
$('#countdown').countDown({
startNumber: 10,
callBack: function (me) {
$(me).text('All done! This is where you give the reward!').css('color', '#090');
}
});
});
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
jquery插件jquery倒計時插件分享_jquery
jquery插件jquery倒計時插件分享_jquery: 代碼如下:$(document).ready(function () { /* 延遲函數 */ jQuery.fn.delay = function (time, func) { return this.each(function () { setTimeout(func, time); }); }; jQuery.fn.countDown = f