هذا هو في الواقع تمرين للأرقام العشوائية JS. أولاً ، قم بتكتب أسماء الجميع في صفيف مقدمًا ، ثم اترك القيم الموجودة في الصفيف يتم عرضها بسرعة في المنطقة. عند الضغط على التوقف ، سيتوقف التمرير لتحقيق تأثير عشوائي.
<! doctype html> <html> <head> <meta charset = "utf-8"/> <title> اسم عشوائي كتبه مدونة JS-QIONGTAI </title> <script type = "text/javascript"> var isrun = var ؛ var a = ["Zhang San" ، "li si" ، "wang wu" ، Array () ؛ Function 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 (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 ؛ width: 100 ٪ ؛"> <div id = "show" style = "margin: auto ؛ font-size: 50px ؛ العرض: 100px ؛ الارتفاع: 50px ؛ الخلفية: #ffeeff"> </div> <div style = "margin-top: 20px ؛