{"id":818,"date":"2013-09-27T09:56:33","date_gmt":"2013-09-27T01:56:33","guid":{"rendered":"http:\/\/www.xiaojia.info\/?p=818"},"modified":"2013-09-27T10:15:14","modified_gmt":"2013-09-27T02:15:14","slug":"js-countdown","status":"publish","type":"post","link":"https:\/\/www.luja.cc\/?p=818","title":{"rendered":"js\u5012\u8ba1\u65f6\u4ee3\u7801"},"content":{"rendered":"<p>\u5c06\u5012\u8ba1\u65f6\u5199\u6210\u4e86js\u51fd\u6570\uff0c\u6765\u8c03\u7528\u3002<br \/>\n\u4ee3\u7801\u5982\u4e0b\uff1a<br \/>\n[javascript]<br \/>\nvar now = new Date();<br \/>\nvar grt= new Date(&#8220;9\/30\/2013 20:00:00&#8221;);<br \/>\nvar ct = grt &#8211; now;<br \/>\nmytime.countdownTime(ct,3,2);<br \/>\n[\/javascript]<br \/>\n<!--more--><br \/>\nhtml\u663e\u793a\u4ee3\u7801\uff1a<br \/>\n[html]<\/p>\n<div id=\"remainTime_g_2\" style=\"color:#000000; width:100%; text-align:center; font-size:45px;\"><\/div>\n<p>[\/html]<\/p>\n<p>\u5012\u8ba1\u65f6js\u51fd\u6570\uff1a<br \/>\n[javascript]<br \/>\nvar mytime = {};<br \/>\nmytime.countdownTime = function(f, d, a) {<br \/>\n    this.remainSec = f \/ 1000;<br \/>\n    if (this.remainSec >= 0) {<br \/>\n        var c = Math.floor(this.remainSec \/ (60 * 60 * 24));<br \/>\n        var b = Math.floor(this.remainSec \/ (60 * 60)) &#8211; (c * 24);<br \/>\n        var h = Math.floor(this.remainSec \/ 60) &#8211; (c * 24 * 60) &#8211; (b * 60);<br \/>\n        var e = Math.floor(this.remainSec) &#8211; (c * 24 * 60 * 60) &#8211; (b * 60 * 60) &#8211; (h * 60);<br \/>\n        if (b >= 0 &#038;&#038; b <= 9) {\n            b = \"0\" + b\n        }\n        if (h >= 0 &#038;&#038; h <= 9) {\n            h = \"0\" + h\n        }\n        if (e >= 0 &#038;&#038; e <= 9) {\n            e = \"0\" + e\n        }\n        msg = \"\" + b + \"\u65f6\" + h + \"\u5206\";\n        if (c != 0) {\n            msg = \"\" + c + \"\u5929\" + msg\n        }\n        msg = msg + e + \"\u79d2\";\n        if (d == \"1\") {\n            msg = \"\u8ddd\u79bb\u5f00\u59cb\uff1a\" + msg\n        } else {\n            msg = \"\u5269\u4f59\uff1a\" + msg\n        }\n        if (c == 0 &#038;&#038; b == 0 &#038;&#038; h == 0 &#038;&#038; e == 0) {\n            if (d != undefined &#038;&#038; d == 1) {\n                if (document.getElementById(\"li_\" + a)) {\n                    var g = $(\"#li_\" + a);\n                    g.find(\"div:first\").attr(\"class\", \"\");\n                    g.find(\"#g_button\").html(\"\u53bb\u770b\u770b\");\n                    g.find(\"#g_button\").attr(\"onclick\", null)\n                }\n            }\n        } else {\n            if (document.getElementById(\"remainTime_g_\" + a)) {\n                document.getElementById(\"remainTime_g_\" + a).innerHTML = msg;\n                setTimeout(\"mytime.countdownTime(\" + (--this.remainSec) * 1000 + \",\" + d + \",'\" + a + \"')\", 1000)\n            }\n        }\n    }\n};\n[\/javascript]\n\n\u53c2\u6570\u91ca\u4e49\uff0cfunction(f, d, a)\nf:\u8bbe\u5b9a\u65f6\u95f4\u51cf\u53bb\u5f53\u524d\u65f6\u95f4\u7684\u4e00\u4e2a\u65f6\u95f4\u5dee\uff0c\u7c7b\u578b\u4e3a\u65f6\u95f4\u6233\u3002\nd:\u5f00\u59cb\u6216\u8005\u5269\u4f59\uff0c\u5f53\u4e3a1\u65f6\uff0c\u8868\u793a\u8ddd\u79bb\u6d3b\u52a8\u5f00\u59cb\u8fd8\u6709\u591a\u4e45\uff0c\u5f53\u5012\u8ba1\u65f6\u6070\u597d\u4e3a0\u65f6\uff0c\u663e\u793a\u6d3b\u52a8\uff0c\u53ef\u4ee5\u70b9\u2018\u53bb\u770b\u770b\u2019\u8fdb\u53bb\u4e86\u3002\u5f53\u4e0d\u4e3a1\u65f6\uff0c\u5176\u5b83\u968f\u673a\u6570\uff0c\u8868\u793a\u5269\u4f59\u5012\u8ba1\u65f6\u3002\na:\u8981\u663e\u793a\u5012\u8ba1\u65f6\u5bb9\u5668\u7684id\u53f7\u3002id\u524d\u7f00\u4e3a\u201cremainTime_g_\u201d\u3002\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c06\u5012\u8ba1\u65f6\u5199\u6210\u4e86js\u51fd\u6570\uff0c\u6765\u8c03\u7528\u3002 \u4ee3\u7801\u5982\u4e0b\uff1a [javascript] var now = new Date( &hellip;<br \/><a href=\"https:\/\/www.luja.cc\/?p=818\">Read more <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[43],"tags":[161,176],"_links":{"self":[{"href":"https:\/\/www.luja.cc\/index.php?rest_route=\/wp\/v2\/posts\/818"}],"collection":[{"href":"https:\/\/www.luja.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.luja.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.luja.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.luja.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=818"}],"version-history":[{"count":4,"href":"https:\/\/www.luja.cc\/index.php?rest_route=\/wp\/v2\/posts\/818\/revisions"}],"predecessor-version":[{"id":822,"href":"https:\/\/www.luja.cc\/index.php?rest_route=\/wp\/v2\/posts\/818\/revisions\/822"}],"wp:attachment":[{"href":"https:\/\/www.luja.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=818"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.luja.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=818"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.luja.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}