惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
C
Cisco Blogs
WordPress大学
WordPress大学
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Cloudflare Blog
小众软件
小众软件
Recent Commits to openclaw:main
Recent Commits to openclaw:main
I
Intezer
Cyberwarzone
Cyberwarzone
T
The Blog of Author Tim Ferriss
博客园 - Franky
F
Fortinet All Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
G
Google Developers Blog
Recent Announcements
Recent Announcements
I
InfoQ
T
Threat Research - Cisco Blogs
V
V2EX
T
Tenable Blog
H
Help Net Security
Cisco Talos Blog
Cisco Talos Blog
T
Tailwind CSS Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
The GitHub Blog
The GitHub Blog
P
Privacy & Cybersecurity Law Blog
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
DataBreaches.Net
罗磊的独立博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
Docker
T
Tor Project blog
Attack and Defense Labs
Attack and Defense Labs
P
Proofpoint News Feed
H
Heimdal Security Blog
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
Martin Fowler
Martin Fowler
AWS News Blog
AWS News Blog
IT之家
IT之家
Google DeepMind News
Google DeepMind News
NISL@THU
NISL@THU
Google Online Security Blog
Google Online Security Blog
Vercel News
Vercel News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
SecWiki News
SecWiki News
GbyAI
GbyAI
P
Proofpoint News Feed
月光博客
月光博客
Schneier on Security
Schneier on Security

博客园 - s80895304

win8 framework3.5安装 ChangeCharToTable sql 触发器 mysql 备忘sql ActiveMQ 安装 【转】j2ee 环境搭建 C#原始类型扩展方法—this参数修饰符 消息队列(Message Queue)简介及其使用 IE中同一个url第二次AJAX调用无法触发onreadystatechange事件 Web Service 身份验证 sql 索引 Memcached、MongoDB、Redis和tokyotyrant 【转】ActiveMQ redis iphone 技巧 10款iOS高效开发必备的Objective-C类库 ASIHTTPRequest Queue 队列 写日志简单应用 js keycode
jquery 倒计时插件
s80895304 · 2011-10-14 · via 博客园 - s80895304

 <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script>
        (function ($) {
            var countdown = function (item, config) {
                var st = new Date(parseInt($(item).attr(config.st)) * 100);
                var et = new Date(parseInt($(item).attr(config.et)) * 100);
                //alert(st.toLocaleString());
                //alert(et.toLocaleString());
                //var seconds = parseInt($(item).attr(config.attribute));
                var seconds = ((et - st) / 1000).toString();
                var timer = null;

                var doWork = function () {
                    if (seconds >= 0) {
                        if (typeof (config.callback) == "function") {
                            var data = {
                                total: seconds,
                                second: Math.floor(seconds % 60),
                                minute: Math.floor((seconds / 60) % 60),
                                hour: Math.floor((seconds / 3600) % 24),
                                day: Math.floor(seconds / 86400)
                            };
                            config.callback.call(item, seconds, data, item);
                        }
                        seconds--;
                    } else {
                        window.clearInterval(timer);
                    }
                }
                timer = window.setInterval(doWork, 1000);
                doWork();
            };
            var main = function () {
                var args = arguments;
                var config = { attribute: 'data-seconds', st: 'st', et: 'et', callback: null };
                if (args.length == 1) {
                    if (typeof (args[0]) == "function") config.callback = args[0];
                    if (typeof (args[0]) == "object") $.extend(config, args[0]);
                } else {
                    config.attribute = args[0];
                    config.callback = args[1];
                }
                $(this).each(function (index, item) {
                    countdown.call(function () { }, item, config);
                });
            };
            $.fn.countdown = main;
        })(jQuery);

    </script>
    <script type="text/javascript">
        $(function () {
            //alert(new Date('2011-10-15').getDay());
            //countdown({ attribute: 'data', callback: function () { }, });
            $('ul').countdown(function (s, d) {
                var items = $(this).find('span');
                items.eq(3).text(d.second);
                items.eq(2).text(d.minute);
                items.eq(1).text(d.hour);
                items.eq(0).text(d.day);
            });
        });
    </script>

<ul data-seconds="10" st="13187455380" et="13187455700">
        <li><span>-</span>天</li>
        <li><span>-</span>时</li>
        <li><span>-</span>分</li>
        <li><span>-</span>秒</li>
    </ul>
    <ul data-seconds="20" st="13187455380" et="13187455790">
        <li><span>-</span>天</li>
        <li><span>-</span>时</li>
        <li><span>-</span>分</li>
        <li><span>-</span>秒</li>
    </ul>
    <ul data-seconds="30" st="13187455380" et="13187455910">
        <li><span>-</span>天</li>
        <li><span>-</span>时</li>
        <li><span>-</span>分</li>
        <li><span>-</span>秒</li>
    </ul>
===========================================================================

var timer;
function TimeDown(id, endDateStr, interval) {
var endDate = new Date(endDateStr);
var nowDate = new Date();
if (endDate <= nowDate) { clearTimeout(timer); return; }
var totalSeconds = parseInt((endDate - nowDate) / 1000);
var days = Math.floor(totalSeconds / (60 * 60 * 24));
var modulo = totalSeconds % (60 * 60 * 24);
var hours = Math.floor(modulo / (60 * 60));
modulo = modulo % (60 * 60);
var minutes = Math.floor(modulo / 60);
var seconds = modulo % 60;

//sb.Append("<span class=\"s1\">0</span> <span class=\"s1\">6</span> <span class=\"s2\">天</span> <span class=\"s1\">2</span> <span class=\"s1\">3</span> <span class=\"s2\">小时</span> <span class=\"s1\">5</span> <span class=\"s1\">9</span> <span class=\"s2\">分</span>");

document.getElementById(id).innerHTML = "还剩:" + days + "天" + hours + "小时" + minutes + "分钟" + seconds + "秒"; //延迟一秒执行自己
var timer = setTimeout(function () { TimeDown(id, endDateStr); }, interval)
}
TimeDown("timer", '2014-11-11', 1000);