Núcleo: objeto matemático e objeto de matriz de js
<! Doctype html> <html lang = "pt"> <head> <meta charset = "utf-8"> <title> aleatória </title> <style> #awardListdom {width): valor) <brat> <brat> <brod> <bod) <bod) <bod) <brod) <bod)) <br> <Label para = "num"> prêmios ganhos </creat> <br> <input type = "text" value = "" id = "num"> <br> <botão id = "submit"> inicie a loteria </butut> <cript>/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * http://www.w3school.com.cn/jsref/jsref_obj_math.asp * -random (): retorna um número aleatório entre 0 e 1. x: Posição inicial, y: obtenha e exclua o número*/ função aleatória (min, max) {return math.floor (min+math.random ()*(max-min)); } var AwardListdom = document.getElementById ("AwardListdom"), num = document.getElementById ("num"), submit = document.getElementById ("submmit"); var awardList=["first prize","second prize","second prize","third prize","third prize","third prize"," third prize","encouragement prize","encouragement prize","encouragement prize","encouragement prize","thank for participation","thank for participation","thank for participation","thank for participation","thank for participation","thank for participação "," obrigado pela participação "]; Listdom.value = Lista de premiação; submit.OnClick = function () {// Array de referência var OldArray = AwardList; var rnum = aleatório (0, OldArray.length); if (OldArray.Length <1) {AwardListdom.value = "Event End"; num.value = "End End"; } else {num.value = OldArray [rnum]; OldArray.splice (rnum, 1); Listdom.value = OldArray; }} </script> </body> </html>Demo: http: //demo.vevb.com/js/2015/choujiang/
Github: https: //github.com/litengdesign/award