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

求大神看看我的为啥没效果

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>无标题文档</title>

<style type="text/css">

*{

margin:0;

padding:0;

}

#box{

position:relative;

left:-200px;

}

.one{

width:200px;

height:200px;

background-color:red;

float:left;

}

.two{

width:50px;

height:50px;

background-color:blue;

float:left;

margin-top:55px;

}

</style>

<script type="text/javascript">

window.onload=function(){

var odiv=document.getElementById("box");

odiv.onmouseover=function(){

starmove()

}

}

function starmove(){

setIntervav(function(){

var odiv=document.getElementById("box");

odiv.style.left=odiv.offsetLeft+10+"px";

},30);

}

</script>

</head>


<body>

<div id="box">

<div class="one"></div>

<div class="two">分享</div>

</div>

</body>

</html>


提问者:李李晨晨 2016-06-10 20:34

个回答

  • lrylong
    2016-06-10 21:16:20

    setInterval写错了