没有任何效果 并且控制台报Unable to set property 'onmouseover' of undefined or null reference 这个错误,望各位大神帮忙
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
.div1{
height: 200px;
width: 200px;
background: red;
position: relative;
left: 0;
opacity: 0.3;
}
</style>
<script >
window.onload=function(){
var Div=document.getElementById('div1')
Div.onmouseover=function(){
startMove(100)
}
Div.onmouseout=function(){
startMove(30)
}
}
var timer=null;
var alpha=30;
function starMove(itarget){
var Div=document.getElementById('div1')
clearInterval(timer);
time=setInterval(function(){
var speed=0;
if(alpha>itarget){
speed=-10;
}else{
speed=10;
}
if(alpha==itarget){
clearInterval(timer);
}else{
alpha+=speed;
Div.style.opacity=alpha/100;
}
})
}
</script>
</head>
<body>
<div class="div1">
</div>
</body>
</html>