{"id":80,"date":"2013-12-06T10:09:53","date_gmt":"2013-12-06T02:09:53","guid":{"rendered":"http:\/\/www.magki.com\/blog\/?p=80"},"modified":"2013-12-06T10:16:08","modified_gmt":"2013-12-06T02:16:08","slug":"simple-timer-by-jquery","status":"publish","type":"post","link":"http:\/\/www.ijony.com\/blog\/2013\/12\/simple-timer-by-jquery.html","title":{"rendered":"\u57fa\u4e8e JQuery \u7684\u7b80\u5355\u8ba1\u65f6\u724c"},"content":{"rendered":"<p>HTML \u90e8\u5206\u4ee3\u7801<\/p>\n<pre>\r\n<div class=\"digits\">\r\n\t<div class=\"clock\">0<\/div>\r\n\t<div class=\"clock\">0<\/div>\r\n\t<div class=\"dot\">:<\/div>\r\n\t<div class=\"clock first\">0<\/div>\r\n\t<div class=\"clock\">0<\/div>\r\n\t<div class=\"dot\">:<\/div>\r\n\t<div class=\"clock first\">0<\/div>\r\n\t<div class=\"clock\">0<\/div>\r\n<\/div>\r\n<\/pre>\n<p>CSS \u90e8\u5206\u4ee3\u7801<\/p>\n<pre>\r\n.digits{ float: left; width: 210px; height: 34px; font-family: Verdana, sans-serif; font-size: 28px; color: #FFF; line-height: 34px; padding-top: 6px;}\r\n.digits div.clock{ float: left; width: 28px; height: 34px; text-align: center; line-height: 34px; background: #000; margin-right: 2px; border-radius: 5px; overflow: hidden;}\r\n.digits div.clock ul{ list-style: none;}\r\n.digits div.clock ul li{ float: left; width: 28px; height: 34px; text-align: center; line-height: 34px;}\r\n.digits div.dot{ float: left; width: 12px; height: 34px;}\r\n<\/pre>\n<p>JS \u90e8\u5206\u4ee3\u7801<\/p>\n<pre>\r\nfunction goTimer(i, n)\r\n{\r\n\tif(!i){\r\n\t\ti = 5;\r\n\t}\r\n\r\n\tif(!n){\r\n\t\tn = '.clock';\r\n\t}\r\n\r\n\tvar c = $(n).eq(i);\r\n\tvar p = c.hasClass('first') ? 6 : 10;\r\n\tvar s = parseInt(c.find('li').eq(0).text());\r\n\r\n\ts = s + 1;\r\n\tif(s === p){\r\n\t\ts = 0;\r\n\t\tgoTimer((i - 1));\r\n\t}\r\n\r\n\tc.find('li').eq(1).text(s);\r\n\tc.children('ul').animate({marginTop: '-34px'}, 'fast', function(){\r\n\t\ttimer++;\r\n\r\n\t\tc.find('li').eq(0).text(s);\r\n\t\tc.children('ul').css({marginTop: '0px'});\r\n\t});\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>HTML \u90e8\u5206\u4ee3\u7801 0 0 : 0 0 : 0 0 CSS \u90e8\u5206\u4ee3\u7801 .digits{ float: left [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/posts\/80"}],"collection":[{"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/comments?post=80"}],"version-history":[{"count":0,"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/posts\/80\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/media?parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/categories?post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/tags?post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}