求助?。。?!
鼠標(biāo)滑過(guò)沒有任何效果,求告知哪里錯(cuò)了
?var a=document.getElementsByTagName("div");
? for(var i=0;i<a.length;i++)
? {
? a[i].onmouseover=function()
? {
?var _this=this.getElementsByTagName("img")[0];
?startMove(_this,{top:-15});
}
? }
? function startMove(obj,json,f)
?{
?clearInterval(obj.time);
var flag=true;
?obj.time=setInterval(function(){
for(var kind in json)
{
var attribute=parseInt(getStyle(obj,kind));
var speed=(json[kind]-attribute)/10;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(attribute!=json[kind])
{
flag=false;
obj.style[kind]=attribute+speed+"px";
}
if(flag)
{
clearInterval(obj.time);
if(f)
f();
}
}
},30);}
?function getStyle(obj,attr)
?{
?if(obj.currentStyle)
?return obj.currentStyle[attr];
?else
?return obj.getComputedStyle(obj,false)[attr];
?}
2016-06-06
var a=document.getElementsByTagName("div");是不是取錯(cuò)標(biāo)簽了,應(yīng)該是var a=document.getElementsByTagName("a");吧