求助JavaScript问题
代码如下,鼠标进入元素后moveTo函数只调用了一次, setTimeout(repeat,interval);没有起作用
function toolListMove(obj,id) {
var setClass=document.getElementById(id);
setClass.className= setClass.className +" toollist-move";
obj.onmouseleave = function(){
setClass.className= "justforposition";
}
}
function moveTo(obj,fin_x,interval){
var divs=obj.getElementsByTagName("div");
divs[0].style.display="block";
var posx=parseInt(divs[0].style.right);
var opc=parseFloat(divs[0].style.opacity);
if(posx<fin_x){
posx=posx+3;
}
if(posx>fin_x){
posx=posx-3;
}
if(opc<1){
opc=opc+0.1;
}
divs[0].style.right=posx+"px";
divs[0].style.opacity=opc;
var repeat="moveTo("+obj+","+fin_x+","+interval+")";
setTimeout(repeat,interval);
}
function cont(){
var t1 = document.getElementById("toollistmove1");
var t2 = document.getElementById("toollistmove2");
var t3 = document.getElementById("toollistmove3");
var t4 = document.getElementById("toollistmove4");
var t5 = document.getElementById("toollistmove5");
var t6 = document.getElementById("toollistmove6");
t1.onmouseenter=function(){
toolListMove(this, t1.id);
moveTo(this,40,100);
};
t2.onmouseenter=function(){
toolListMove(this, t2.id);
moveTo(this,40,100);
};
t3.onmouseenter=function(){
toolListMove(this, t3.id);
moveTo(this,40,100);
};
t4.onmouseenter=function(){
toolListMove(this, t4.id);
moveTo(this,40,100);
};
t5.onmouseenter=function(){
toolListMove(this, t5.id);
moveTo(this,40,100);
};
t6.onmouseenter=function(){
toolListMove(this, t6.id);
moveTo(this,40,100);
};
}
window.onload=cont;