이것은 실제로 JS 랜덤 숫자에 대한 연습입니다. 먼저 모든 사람의 이름을 배열에 사전에 기록한 다음 배열의 값을 해당 영역에 빠르게 표시하도록하십시오. STOP을 누르면 스크롤링이 중지되어 무작위 효과를 얻습니다.
<! doctype html> <html> <head> <meta charset = "utf-8"/> <title> js-qiongtai blog </title> <script type = "text/javascript"> var isrun = true; var a = [zhang sait ","li si ","wang wu ","zhao liu "] array (); 함수 action (str) {var s = document.getElementById ( "bt"). value; value; if (s == "start") {isrun = true; run (); hune (); getElementById ( "bt"). value = "end";} else {isrun = false; document.getElementById ( "bt"); math.floor (math.random () * a.length+ 1) -1; document.getElementById ( "show"). innerHtml = a [i]; if (isrun == false) {var b = true; for (var j in a2) {if (a2 [j] == i) {b = false; a2 [a2.length] = i; return;}} settimeout ( "run ()", 10);} </script> </head> <body> <div style = "text-align : center; margin-top : 100px : 100%;"> <div id = "show" Style = "margin : auto; font-size : 50px; 너비 : 100px; 높이 : 50px; 배경 : #feeff"> </div> <div style = "margin-top : 20px;"> <입력 id = "bt"type = "button"onclick = "action ()" "시작"/> </div> </html> </html> </html>