<!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>
body,div,span{
margin:0;
padding:0;
}
#first{
width:200px;
height:200px;
position:relative;
background:#F00;
cursor:pointer;
top:0;
left:-200px;
}
#first span{
background:#00C;
width:30px;
height:50px;
border-radius:2px;
font-size:20px;
text-align:center;
position:absolute;
left:200px;
top:75px;
color:#FFF;
}
</style>
<script type="text/javascript">
window.onload=function(){
var oDiv=document.getElementById('#first');
oDiv.onmouseover=function(){
starMove();
}
}
var timer=null;
function starMove(){
clearInterval(timer);
var oDiv=document.getElementById('#first');
timer=setInterval(function(){
if(oDiv.offsetLeft==0){
clearInterval(timer);
}else{
oDiv.style.left=oDiv.offsetLeft+10+'px';
}
},30)
}
</script>
</head>
<body>
<div id=first><span>分享</span></div>
</body>
</html>
这是他的错误提示:Uncaught TypeError: Cannot set property 'onmouseover' of null
qq_非诚勿扰_3
qq_二冬_0
相关分类