为什么这样无法实现呢?求解答 /(ㄒoㄒ)/~~ 代码如下
<body>
<div class='title'>开始抽奖啦!</div>
<div class='btns' >
<span class='start'>开 始</span>
<span class='stop'>结 束</span>
</div>
<script>
var data=['红米','白米','小米','大米','黑米','恭喜抽中骚猪','谢谢惠顾'];
window.onload=function(){
var start=document.getElementsByClassName('start');
var stop=document.getElementsByClassName('stop');
var title=document.getElementsByClassName('title');
start.onclick=function(){
timer=setInterval(function(){
var random=Math.floor(Math.random()*data.length);
console.log(random);
// title.innerHTML=data[random];
},50);
}
}
</script>
</body>