问答详情
源自:2-1 JS速度动画

为什么代码都一样,就是跑不起来?

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

<style>

#small{

width: 200px;

height: 200px;

left: -200px;

position: relative;

background-color: red;

}

</style>

<script>

window.onload=function(){

var div1=document.getElementById('samll');

div1.onmouseover=function(){

startfun();

}

}

function startfun(){

var div1=document.getElementById('samll');

setInterval(function(){

div1.style.left=div1.offsetLeft+10+'px';

},30)

}

</script>

</head>

<body>

<div id="small"></div>

</body>

</html>


提问者:不蒸馒头争口气 2017-09-05 10:04

个回答

  • 慕粉1729504738
    2017-09-05 11:04:59
    已采纳

    getElementById('samll');

    small拼错了,大兄弟


  • 传说的女程序媛就是我啊啊啊啊啊
    2017-09-05 11:16:07

    你名字写错了,var div1=document.getElementById('samll');你自己写的small,但是变成samll,当然不对了