<!doctype?html>
<html>
?<head>
???<title>抽獎</title>
???<meta?charset="utf-8">
???<style?type="text/css">
???????*{margin:0;padding:0;}
????????#title{
????????????width:380px;height:70px;line-height:70px;
????????????color:red;font-size:24px;font-weight:bold;
????????????text-align:center;margin:0?auto;
????????}
????????.btns{width:190px;height:30px;margin:0?auto;overflow:hidden;}
????????.btns?span{
????????????display:block;width:83px;height:?28px;line-height:?28px;background:?#003366;
????????????color:?#fff;font-size:?14px;
????????????border:?1px?solid?#003366;border-radius:?7px;
????????????text-align:?center;margin:?0?5px;
????????????float:?left;
????????}
???</style>
?</head>
?<body>
????<div?id="title"?class="title">開始抽獎啦!</div>
????<div?class="btns">
???????<span?id="play">開?始</span>
???????<span?id="stop">停?止</span>
????</div>
????<script?type="text/javascript">
????????????var?data=['Phone5','Ipad','三星筆記本','佳能相機','惠普打印機','謝謝參與','50元充值卡','1000元超市購物券'];
????????????var?timer=null;
????????????window.onload=function(){
????????????????var?title=document.getElementById('title'),
????????????????????play=document.getElementById('play'),
????????????????????stop=document.getElementById('stop');
????????????????????play.onlick=playFun;
????????????????????stop.onlick=stopFun;
????????????};
????????????function?playFun(){
????????????????var?play=document.getElementById('play');
????????????????
????????????????timer=setInterval(function(){
????????????????????//?var?index=Math.floor(Math.random()*data.length);
????????????????????//?title.innerHTML=data[index];
????????????????????console.log('hello');
????????????????},50);
????????????????play.style.background="#999";
????????????}
????????????function?stopFun(){
????????????????clearInterval(timer);
????????????}
????????????
????</script>
?</body>
</html>
2017-07-31
第38行 應該是play.onclick,你寫成了onlick,少了個c。
39行同理