function randomNum(){
var r = Math.floor(Math.random() * 8);
var str = "崔涛|徐敏学|陈阳|殷佳美|崔涛|徐敏学|陈阳|殷佳美"
var arr = str.split('|');
document.getElementById('in').value = arr[r];
}
var time;
var a;
var flag=0;
document.getElementById('start')
.addEventListener('click',function(){
if(flag==0)
time = setInterval(randomNum,100);
flag=1;
});
document.getElementById('end')
.addEventListener('click',function(){
clearInterval(time);
flag=0;
});
window.onkeydown=function(e){
console.log(e.keyCode);
console.log(flag);
if(e.keyCode==13&&flag==0)
{
time = setInterval(randomNum,100);
flag=1;
}
else if(e.keyCode==13&&flag==1)
{
clearTimeout(time);
flag=0;
}
}
李晓健
相关分类