{"id":1450,"date":"2015-02-26T17:09:55","date_gmt":"2015-02-26T09:09:55","guid":{"rendered":"http:\/\/www.gaigaiming.com\/?p=1450"},"modified":"2015-02-26T17:09:55","modified_gmt":"2015-02-26T09:09:55","slug":"%e8%87%aa%e5%8a%a8%e5%88%87%e6%8d%a2%e9%80%89%e9%a1%b9%e5%8d%a1","status":"publish","type":"post","link":"https:\/\/www.gaigaiming.com\/index.php\/2015\/02\/26\/%e8%87%aa%e5%8a%a8%e5%88%87%e6%8d%a2%e9%80%89%e9%a1%b9%e5%8d%a1\/","title":{"rendered":"\u81ea\u52a8\u5207\u6362\u9009\u9879\u5361"},"content":{"rendered":"<p>\/\/clearInterval(ID)<br \/>\n\/\/setInterval(\u51fd\u6570\u540d\uff0c\u65f6\u95f4)setInterval() \u65b9\u6cd5\u4f1a\u4e0d\u505c\u5730\u8c03\u7528\u51fd\u6570\uff0c\u76f4\u5230 clearInterval() \u88ab\u8c03\u7528\u6216\u7a97\u53e3\u88ab\u5173\u95ed\u3002\u7531 setInterval() \u8fd4\u56de\u7684 ID \u503c\u53ef\u7528\u4f5c clearInterval() \u65b9\u6cd5\u7684\u53c2\u6570\u3002<br \/>\n\/\/oLi[i].index=i; \u51fa\u73b0\u95ee\u9898\u4e3a\u201c\u65e0\u6cd5\u83b7\u53d6\u672a\u5b9a\u4e49\u6216 null \u5f15\u7528\u7684\u5c5e\u6027\u2018style\u2019\u201d<br \/>\n\/\/\u8fbe\u5230\u7684\u6548\u679c\uff0c\u70b9\u51fb\u524d\u8fdb\u548c\u540e\u9000\u7686\u53ef<br \/>\n\/\/\u95ee\u9898\u70b9\uff1a\u5f53\u629b\u51fa\u70b9\u51fb\u7bad\u5934\uff0c\u76f4\u63a5\u70b9\u51fbonclick\u540e\uff0c\u518d\u70b9\u51fb\u7bad\u5934\u51fa\u73b0\u95ee\u9898\uff0c\u56de\u5f52\u5230\u7b2c\u4e00\u4e2a\u7bad\u5934\uff0c\u4e0d\u80fd\u4ece\u5f53\u524d\u7684\u5730\u65b9\u5f00\u59cb\u3002\u8054\u7cfb\u8d77\u6765iNow\u548cthis.index<br \/>\n\/\/clearInterval() \u65b9\u6cd5\u53ef\u53d6\u6d88\u7531 setInterval() \u8bbe\u7f6e\u7684 timeout\u3002<br \/>\n\/\/clearInterval() \u65b9\u6cd5\u7684\u53c2\u6570\u5fc5\u987b\u662f\u7531 setInterval() \u8fd4\u56de\u7684 ID \u503c\u3002\u8bed\u6cd5clearInterval(id_of_setinterval)\u9664\u6389,\t\u5fc5\u987b\u8981\u8fd4\u56de\u7684\u6570\u503c\uff0c\u53e5\u67c4\uff0csetInter<br \/>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\"><br \/>\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><br \/>\n<head><br \/>\n<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/><br \/>\n<title>\u65e0\u6807\u9898\u6587\u6863<\/title><\/p>\n<style>\n.wp{width:500px;}\nul li{ float:left; list-style:none; list-style-type:none; padding:5px 10px;}\n#con li{ width:400px; display:none; background:red; height:200px;  color:#fff; text-align:center;}\n.red{color:#fff; background:red;}\n<\/style>\n<p><\/head><\/p>\n<p><body><\/p>\n<div class=\"wp\">\n<ul id=\"menu\">\n<li class=\"red\">\u83dc\u5355\u4e00<\/li>\n<li>\u83dc\u5355\u4e8c<\/li>\n<li>\u83dc\u5355\u4e09<\/li>\n<li>\u83dc\u5355\u56db<\/li>\n<\/ul>\n<ul id=\"con\">\n<li style=\"display:block\">\u5185\u5bb9\u4e00<\/li>\n<li>\u5185\u5bb9\u4e8c<\/li>\n<li>\u5185\u5bb9\u4e09<\/li>\n<li>\u5185\u5bb9\u56db<\/li>\n<\/ul>\n<p><span id=\"next\">\u2192<\/span><br \/>\n<span id=\"prev\">\u2190<\/span>\n<\/div>\n<p><\/body><br \/>\n<script>\nvar menu=document.getElementById(\"menu\");\nvar oLi=menu.getElementsByTagName(\"li\");\nvar con=document.getElementById(\"con\");\nvar oCon=con.getElementsByTagName(\"li\");\nvar next=document.getElementById(\"next\");\nvar prev=document.getElementById(\"prev\");\nvar iNow=0;\nfor(var i=0;i<oLi.length;i++){\n\toLi[i].index=i;\n\toLi[i].onclick=function(){\n\t\tiNow=this.index;\n\t\tclearInterval(timer);\n\t\tfor(var j=0;j<oLi.length;j++){\n\t\t\toLi[j].className=\"\";\n\t\t\toCon[j].style.display=\"none\";\n\t\t\t}\n\t\t\toCon[iNow].style.display=\"block\";\n\t\t\tthis.className=\"red\";\n\t\t}\n\t\n\t}\n\nvar timer=setInterval(move,1000)\nfunction move(){\t\n\tfor(var j=0;j<oLi.length;j++){\n\t\t\toLi[j].className=\"\";\n\t\t\toCon[j].style.display=\"none\";\n\t  }\n\t  iNow++;\n\t  if(iNow==oLi.length)iNow=0;\n\t  oCon[iNow].style.display=\"block\";\n\t  oLi[iNow].className=\"red\";\n\t}\nnext.onclick=function(){\n\tclearInterval(timer);\n\talert(111);\n\tmove();\n\t}\nprev.onclick=function(){\n\tclearInterval(timer);\n\tfor(var j=0;j<oLi.length;j++){\n\t\t\toLi[j].className=\"\";\n\t\t\toCon[j].style.display=\"none\";\n\t  }\n\tiNow--;\n\tif(iNow==-1)iNow=oLi.length-1;\n\toCon[iNow].style.display=\"block\";\n\toLi[iNow].className=\"red\";\n\t}\n\t\n<\/script><br \/>\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/clearInterval(ID) \/\/setInterval(\u51fd\u6570\u540d\uff0c\u65f6\u95f4)setInterval()  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1450","post","type-post","status-publish","format-standard","hentry","category-4"],"_links":{"self":[{"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/posts\/1450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/comments?post=1450"}],"version-history":[{"count":0,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/posts\/1450\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/media?parent=1450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/categories?post=1450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/tags?post=1450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}