求,提示这个是我哪里错了呀?怎么改?Uncaught TypeError: Cannot set property 'onmouseover' of null

来源:4-1 JS多物体动画

xld

2016-05-11 11:55

<script type="text/javascript">

window.onload = function(){

var chgOpacity=document.getElementById('chgOpacity');

oShareSide.onmouseover = function (){

startMove(0);

}

oShareSide,onmouseout = function(){

startMove(-200);

}

}

var chgOpacity=document.getElementById('chgOpacity');

chgOpacity.onmouseover = function (){

startChgOpac(100);

}

chgOpacity.onmouseout = function(){

startChgOpac(30);

}

var doing = null;

var alpha = 30;

function startChgOpac(iTarget){

clearInterval(doing);

doing = setInterval(function(){

var speeds = 0;

if (alpha > iTarget) {

speeds = -10 ;

}else{

speeds = 10;

}

if(alpha == iTarget){

clearInterval(doing);

}else{

alpha += speeds;

chgOpacity.style.filter='alpha(opacity='+alpha+')';

chgOpacity.style.opacity = alpha/100;

}

},30);

}


写回答 关注

2回答

  • mirrorofsky
    2016-05-16 15:46:20
    已采纳

    1.var chgOpacity=document.getElementById('chgOpacity');

    oShareSide.onmouseover = function (){     //oShareSide.onmouseover 改为chgOpacity.onmouseover 

    2.oShareSide  //这个变量没有声明过,所以oShareSide.onmouseover为null。


    xld

    非常感谢!

    2016-06-06 10:55:46

    共 1 条回复 >

  • linux2011
    2016-05-11 14:08:37

    oShareSide哪取得?

JS动画效果

通过本课程JS动画的学习,从简单动画开始,逐步深入各种动画框架封装

113925 学习 · 1443 问题

查看课程

相似问题