还是没有效果?用的firfox.不知道为什么?
<!DOCTYPE HTML>
<html>
<head>
<title>JS动画</title>
<meta charset="UTF-8">
<script type="text/javascript">
window.onload = function(){
var share = document.getElementById("div1");
share.onmouseover = function(){
Move();
}
}
var timer=null;
function Move(){
clearInterval(timer);
var share = document.getElementById("div1");
var timer = setInterval(function(){
if (share.offsetLeft ==0 ){
clearInterval(timer);//让整个div1显示完毕后停止向右移动
}else{
share.style.left = share.offsetLeft+10+'px';
}
},30);
}
</script>
<style type="text/css">
*{
margin: 0px;
padding: 0px;
}
.div1{
width: 300px;
height: 300px;
background-color: #F66;
position: relative;
left: -300px;
}
.div1 span{
width: 50px;
height: 60px;
background-color: blue;
position: absolute;
left: 300px;
top: 120px;
line-height: 60px;
color: #fff;
}
</style>
</head>
<body>
<div>
<span>share</span>
</div>
</body>
</html>