来不及的拥抱
2015-09-19 15:32
<style>
*{margin:0;padding:0;}
#div1{width:300px;height:300px;background:#ccc;position:relative;left:-300px;}
#div1 span{display:block;width:50px;height:100px;position:absolute;left:300px;background:#06F;}
</style>
</head>
<body>
<div id="div1"><span>分享</span></div>
<script>
window.onload = function(){
var oDiv = document.getElementById("div1");
oDiv.onmouseover = function(){
startMove();
}
}
function starMove(){
var oDiv = document.getElementById("div1");
setInterval(function(){
oDiv.style.left = ODiv.offsetLeft+10+'px';
},30)
}
</script>
<style>body,div,span{margin:0;padding:0;}#div1{background-color: #F00;height: 200px;width: 200px;
position: relative;left: -200px;top:10px;}#div1 #share{width:20px;height:50px;background-color:#00F;
position:absolute;left:199px;top:78px;}</style><scriptlanguage="text/javascript">window.onload=function(){ var oDiv=document.getElementById("div1"); oDiv.onmouseover=function(){ startMove(0);}
oDiv.onmouseout=function(){ startMove(-200); }} var timer=null;function startMove(iTarget){ clearInterval(timer); var oDiv =document.getElementById("div1"); timer=setInterval(function(){
var speed=0; if(oDiv.offsetLeft>iTarget){ speed=-10; }else{speed=10; } if(oDiv.offsetLeft==iTarget){
clearInterval(timer); } else{ oDiv.style.left=oDiv.offsetLeft+speed+"px"; } },30) }</script></head>
可以帮忙看一下代码吗?我的效果也不出来,查看了好多遍都没发现错误
肯定没有啦,函数名和变量名都写错了怎么会有效果呢
JS动画效果
113925 学习 · 1443 问题
相似问题