clearTimeout怎么用
托泥羊 2014-09-14 11:03:56 下面这个函数怎么结束掉setTimeout??
function moveToTop(classNa,distenceInit,distence,speed)
{
console.debug("start......");
element=document.getElementsByClassName(classNa)[0];
var topTemp=parseInt(element.style.top);
console.debug("topTemp:"+topTemp);
if (topTemp <= (distenceInit - distence)) {
clearTimeout(t); //——这个怎么不起作用啊???
console.debug("end if,truely end......");
} else {
topTemp--;
element.style.top = topTemp + "px";
}
var repeat = "moveToTop('" + classNa + "'," + distenceInit + "," + distence + "," + speed + ")";
t = setTimeout(repeat, speed);
}