Core: Objeto matemático y objeto de matriz de JS
<! Doctype html> <html lang = "en"> <head> <meta charset = "utf-8"> <title> aleatorio </title> <style> #awardlistdom {width: 100%;} </style> </head> <body> <label para = "premio"> premiar lista </etiqueta> <bebr> <put type = "text" value "Id" id " <br> <etiqueta for = "num"> premios ganados </label> <br> <input type = "text" value = "" id = "num"> <br> <button id = "enviar"> Inicie la lotería </botón> <script>/ * * Idea: lotería aleatoria, dibuje un premio y reduzca un método de objetos matemáticos *:: http://www.w3school.com.cn/jsref/jsref_obj_math.asp * -random (): devuelve un número aleatorio entre 0 y 1. * -floor (): Get entero * Operación de matriz: * -empalme (x, y); x: Inicie la posición, y: obtenga y elimine el número*/ function Random (min, max) {return math.floor (min+math.random ()*(max-min)); } var premioListdom = document.getElementById ("Awardlistdom"), num = document.getElementById ("num"), subt = document.getElementById ("enviar"); var premioList = ["primer premio", "segundo premio", "segundo premio", "tercer premio", "tercer premio", "tercer premio", "tercer premio", "Premio de aliento", "Premio de aliento", "Premio de aliento", "Premio de aliento", "agradecimiento por la participación", "Agradecido por la participación", gracias por la participación "] por la participación". PremioListdom.Value = ANSTRAYLIST; Subt.OnClick = function () {// reference array var OldArray = premioList; var rnum = Random (0, OldArray.length); if (OldArray.length <1) {premioLInstdom.Value = "Event End"; num.Value = "Event End"; } else {num.Value = OldArray [rnum]; OldArray.splice (rnum, 1); PremioListdom.Value = OldArray; }} </script> </body> </html>demostración: http: //demo.vevb.com/js/2015/choujiang/
github: https: //github.com/litengdesign/award