基于JS实现的随机数字抽签实例_javascript技巧_脚本之家

话不多说,附上源码,仅供大家参考

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持脚本之家!

    var numArray = new Array(); var personNum = 30; $ { for (var i = 0; i < personNum; i++) { numArray[i] = i; } $.click { var n = Math.floor * numArray.length + 1) - 1; //生成随机数 $.text; numArray.splice; $.click { var totalArray = new Array.each { totalArray[i] = v.innerText; }); var n = Math.floor * totalArray.length + 1) - 1; //生成随机数 this.value = totalArray[n]; $.each { if (v.innerText == $ { this.style.background = "red"; } else { this.style.background = "white"; } }); }); });   ul { /*display: block; float:left;*/ } ul li { width: 150px; height: 150px; line-height: 150px; border: 1px solid gray; float: left; margin-left: 10px; margin-top: 10px; list-style-type: none; text-align: center; font-size: 20px; } #btnStart { width: 100px; height: 30px; margin-left: 10px; margin-top: 10px; }    click me! click me! click me! click me!   click me! click me! click me! click me!   click me! click me! click me! click me!   click me! click me! click me! click me!   click me! click me! click me! click me!   

发表评论

电子邮件地址不会被公开。 必填项已用*标注

相关文章