_沐雨
2017-04-30 11:29
错误提示加了注释的2行有问题!
只能有第一个动画,第二个无法进行。错误一直累计。百度没找到解决方法,求教!
op.onmouseover=function(){yd(this,"height",300,function(){yd(this,"width",400);});}
op.onmouseout=function(){yd(this,"height",150,function(){yd(this,"width",200);});}
function getStyle(obj,attr)
{
if(obj.currentStyle){return obj.currentStyle[attr];}
//else { return getComputedStyle(obj,false)[attr];}
}
//iccr=parseInt(getStyle(obj,attr));
我猜是this的的作用域问题,onmouseover内的function函数应该把this传参,因为第二个function中的this不再指向op本身。相关的this 问题我也不太明白,正学习
应改为
op.onmouseover = function() {
var that = this //将this传参
yd(that, "height", 300, function() {
yd(that,"width",400); });
}
不知道对不对,共勉。
谢谢你,我想起来了,
JS动画效果
113916 学习 · 1502 问题
相似问题
回答 2