亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

更好地實現這段代碼的效果的 寫法

更好地實現這段代碼的效果的 寫法

啊啊啊啊123 2017-03-18 11:22:41
<!DOCTYPE?HTML> <html> <head> <meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"> <title>無標題文檔</title> <style> #container?div{ width:?50px; height:?50px; background-color:?red; position:?absolute; top:?40px; left:?0px; margin-right:?10px; } #container?.on{ background-color:?yellow; } </style> <script> window.onload?=?function?()?{ var?btn1?=?document.getElementsByTagName('button')[0]; var?container?=?document.getElementById('container'); var?box?=?container.getElementsByTagName('div'); var?str?=?''; for?(var?i?=?0;?i?<?10;?i++)?{ str?+=?'<div></div>'; }; container.innerHTML?=?str; for?(var?i?=?0;?i?<?box.length;?i++)?{ box[i].style.left?=?80*i?+?'px'; } btn1.onclick?=?go; var?num?=?0; function?go()?{ //if?(num?<?10)?{ clearInterval(box.timer); box.timer?=?setInterval(?function?()?{ for?(var?i?=?0;?i?<?box.length;?i++)?{ box[i].className?=?''; }; box[num].className?=?'on'; num++; if?(num?>=?10)?{ clearInterval(box.timer); num?=?0; num1?=?9; go1(); }; //box[num-1].className?=?'on'; //num?%=?box.length;//循環 },?100); //} }; //var?num1?=?9; function?go1()?{ if?(num1?>=?0)?{ clearInterval(box.timer); box.timer?=?setInterval(?function?()?{ for?(var?i?=?0;?i?<?box.length;?i++)?{ box[i].className?=?''; }; box[num1].className?=?'on'; num1--; if?(num1?==?-1)?{ clearInterval(box.timer); //num1?=?9; }; },?100); } }; }; </script> </head> <body> <button>go</button> <div?id="container"></div> </body> </html>覺得這么寫很麻煩,求更簡單的實現法子
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 1531 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號