Dies ist tatsächlich eine Übung für JS -Zufallszahlen. Schreiben Sie zuerst die Namen aller in einem Array im Voraus auf und lassen Sie die Werte im Array schnell in der Region angezeigt. Wenn Sie Stopp drücken, wird das Scrollen stehen, um einen zufälligen Effekt zu erzielen.
<! DocType html> <html> <head> <meta charset = "utf-8"/> <title> Zufallsname von JS-Qiongtai Blog </title> <script type = "text/javascript"> var isrun = true; var a = ["zhang san", li si, "Wang WUG", "WANG WUG", "WANG WUS", "WANG WUS", "WANG WUS", "WANG WU", "," WANG WUS "," WANG WU ",", "WANG WUS", "," WANG WUS "," WANG WU ",", "WANG WUS", "," WANG WUS ",", "WANG WUS", "," WANG WUS ",", " action (str) {var s = document.getElementById ("bt"). value; if (s == "start") {isrun = true; run (); document.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; für (var j in a2) {if (a2 [j] == i) {b = false;}}}}}}} {b) {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{b) a2 [a2.Length] = i; return;}} setTimeout ("run ()", 10);} </script> </head> <body> <div style = "text-align: center; margin-top: 100px; width: 100%;"> <div id = "show" style="margin:auto;font-size:50px;width:100px;height:50px;background:#FFEEFF"></div><div style="margin-top:20px;"><input id="bt" type="button" onclick="action()" value="start"/></div></div></body></html>