これは実際にはJS乱数の演習です。まず、すべての人の名前を事前に配列に書き留めてから、配列内の値をエリアにすばやく表示します。停止を押すと、スクロールが停止してランダム効果が得られます。
<!doctype html> <html> <head> <meta charset = "utf-8"/> <title> js-qiongtaiブログによって書かれたランダム名</title> <script type = "text/javascript"> var isrun = true; var a = ["zhang san"、 "li si"; "zhao"; "zhao"; action(str){var s = document.getElementbyid( "bt")。value; if(s == "start"){isrun = true; run(); document.getElementByid( "bt")。value = "end";} Math.floor(math.random() * a.length+ 1)-1; document.getElementByid( "show")。innerhtml = a [i]; if(isrun == false){var b = true; for(a2){if(a2 [j] == i){b = fals;} if(b){b){ a2 [a2.length] = i; return;}} setimeout( "run()"、10);} </script> </head> <body> <div style = "text-align:center; margin-top:100px; width:100%;"> <div id = "show" " style = "マージン:auto; font-size:50px; width:100px; height:50px; background:#ffeeff"> </div> <div style = "mirgn-top:20px;"> <input id = "bt" type = "button" onclick = "action()" value = "start"/> </div> </body> </html>