JS简单随机点名

Document .box{ position: relative; } .box1{ margin: 0px 50%; right: -10px; margin-top: 50px; } .box2{ border: 1px solid red; width: 200px; height: 200px; text-align: center; line-height: 200px; position: absolute; margin: 0px 50%; right: -100px; background-color: grey; color: pink; } .ipt{ border: 1px solid grey; width: 40px; height: 16px; background-color: grey; }
var btn1=document.getElementById('btn1'); var des = document.getElementById('des'); var sum=['张三','李四','王五','赵六','邢达','昊','张溥','张响']; btn1.onclick=function(){ var n=Math.floor(Math.random()*sum.length); des.value=sum[n]; }


猜你喜欢

转载自blog.csdn.net/weixin_42236466/article/details/82556024