欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Jquery倒計時源碼分享

 更新時間:2014年05月16日 08:57:45   作者:  
這是一個基于jquey寫的倒計時。當然代碼有點小改動,只是改了一下展示效果。

在靜態(tài)頁添加顯示倒計時的容器,并引用下面腳本,代入時間參數即可使用。

timeoutDate——到期時間,時間格式為2014/01/01或2014/1/1

D——天

H——小時

M——分鐘

S——秒

xs——數字0~9

效果圖:

代碼展示:

html:

復制代碼 代碼如下:

<span id="top_tuan_countdown"></span>

jquery:

復制代碼 代碼如下:

$().ready(function () {
    CcountDown([, , timeoutDate], ['還有&nbsp;<b><font color="#ff0000" size="4">D</font>&nbsp;天&nbsp;</b><b><font color="#ff0000" size="4">H</font>&nbsp;時&nbsp;</b><b><font color="#ff0000" size="4">M</font>&nbsp;分&nbsp;</b><b><font color="#ff0000" size="4">S</font>&nbsp;秒&nbsp;</b><b><font color="#ff0000" size="4">xs</font></b>&nbsp;到期', '', ''], '#top_tuan_countdown', function () { $('#top_tuan_countdown').remove() });
})
function CcountDown(t, c, _self, fn) {
    function nd(d) {
        return isNaN(d) ? (d ? new Date(d).getTime() : new Date().getTime()) : d * 1000;
    }
    var e = [nd(t[0]), nd(t[1]), nd(t[2])], _s = _self, b;
    if (t[0] && e[0] > e[1]) {
        $(_s).html(c[1]);
        return;
    } else if (e[1] > e[2]) {
        fn && fn($(_s));
        $(_s).html(c[2]);
        return;
    }
    (b = function (l) {
        var l = l || (e[2] - e[1]) / 100, k = {
            D: l / 36000 / 24, H: l / 36000 % 24, M: l / 600 % 60, S: l / 10 % 60, xs: l % 10
        };
        $(_s).html(c[0].replace(/D|H|M|S|xs/g, function (m) {
            var n = parseInt(k[m]) + ''
            if (n.length == 1 && m != 'D' && m != 'xs') {
                n = 0 + n;
            }
            return n
        }));
        setTimeout(function () {
            b(l - 1)
        }, 100);
    })()
}

相關文章

最新評論