why my setTimout is not working
Can anyone see why the below is not working? It does not fade in?
$(titleWrap).hover(
function(){
//$(this.nextSibling).delay(1000).fadeIn("slow");
t = setTimeout(function(){$(this.nextSibling).fadeIn("slow")},1000);
},
function(){
clearTimeout(t);
}
);
teammatt3 posted this at 02:08 — 11th May 2010.
He has: 2,102 posts
Joined: Sep 2003
In this line
t = setTimeout(function(){$(this.nextSibling).fadeIn("slow")},1000);
"this" refers to the global object (the window). You need something like
$(titleWrap).hover(
function(){
var that = this; // keep a reference to 'this' since you lose it in the setTimeout callback
t = setTimeout(function(){$(that.nextSibling).fadeIn("slow")},1000);
},
function(){
clearTimeout(t);
}
);
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.