猿问

js在浏览器不报错是为什么?而且就算用下载的课件写也不运行为什么啊?

<!DOCTYPE html>

<html>

<head>

<title>抽奖</title>

<meta charset="utf-8">

<link rel="stylesheet" type="text/css" href="css/style.css">

<script type="text/javascript" scr="js/jss.js"></script>

</head>

<body>

<div id="title" class="title">开始抽奖啦!</div>

<div class="btns">

<span id="play">开 始</span>

<span id="stop">结 束</span>

</div>

</body>

</html>

var data=['iphone6s','honor5x','mate8','p9','v8','100元代金券'],

timer=null,

flag=0;


window.onload=function(){

var play=document.getElementById('play'),

stop=document.getElementById('stop');


//开始抽奖

//鼠标事件

play.onclick=playFun;

stop.onclick=stopFun;


//键盘事件

document.onkeyup=function(event){

event = event || window.event;

if (event.keycode==13) {

if (flag==0) {

playFun;

flag=1

   } else {

    stopFun;

    flag=0;

   }

}

}


}


function playFun(){

var title=getElementById('title'),

play=getElementById('play');

clearinterval(timer);

timer=setInterval(

function(){

var random=Math.floor(Math.random()*data.length);

title.innerHTML=data[random];

},50)

play.style.background='#999';

}

function stopFun(){

clearinterval(timer);

var play=getElementById('play');

play.style.background='#036';

}


C佳
浏览 1299回答 1
1回答
随时随地看视频慕课网APP
我要回答