哪里錯(cuò)了?
<title>無標(biāo)題文檔</title>
</head>
<style>
#div1{width:200px;
height:200px;
background:red;
position:absolute;
left:0;
top:200px;
}
</style>
<script>
window.onload=function(){
var oDiv=document.getElementById("star");
star.onclick= function(){
? starmove(300);
}
}
var timer=null
function starmove(iTarget){
clearInterval(timer);
var oDiv=document.getElementById("div1");
timer=setInterval(function(){
? ? if(oDiv.offsetLeft==iTarget){
? ? ? clearInterval(timer);
? ? }else{
? ? ? oDiv.style.left = oDiv.offsetLeft+speed+"px";
? ? }
?
},30)
}
</script>
<body>
<input ?id=star type="button" value="開始"/>
<div id=div1>
</div>
</body>
</html>
2016-12-13
speed沒定義,id沒有雙引號(hào)