Home > front end >  Bosses do me a favor, please don't write JS
Bosses do me a favor, please don't write JS

Time:10-04

Design a web page, for the annual meeting of the draw, cycle show everyone's name, when press the space bar to stop circulation to stay in the current name

CodePudding user response:

<body>
First prize: one million & lt;/div>

<script>

Var arr=[' name ', 'name', 'name', 'name', 'name', 'name', 'name', 'name', 'name'].
Var oDiv=document. GetElementsByTagName (" div ") [0];
Var oBut=document. GetElementsByTagName (" button ") [0];
//random play
Var timer=setInterval (function () {

Var index=parseInt (Math. The random () * arr in length).
ODiv. InnerHTML=arr [index];
}, 10);


</script>


Call the blank space key code but give him a clear when press the timer clearInterval (timer);
  • Related