I've added setTimeout to a couple of functions, in one it is running fine but in another it doesn't seem to run at all. I can't tell why as it's exactly the same. Please find below my code, any help would be appreciated.
It's the setTimeout line I'm looking at.This one works fine.
var fctyhov = function (z) {
$(deptmts[i]).hover(
function(){
$(fcultys[z]).stop(true).animate({color: col1});
setTimeout(function(){$(z).css("text-shadow", tsh1);},100);},
function(){
$(fcultys[z]).stop(true).animate({color: col3});
setTimeout(function(){$(z).css("text-shadow", tsh2);},100);}
);
};
But this one doesn't
var facdth = function (y,x,w) {
$(y).hover(
function(){
$(x).stop(true).fadeTo("fast", 1);
$(w).stop(true).delay().animate({color:col1});
$(y).stop(true).animate({color: col1});
setTimeout(function(){$(y).css("text-shadow", tsh1);},100);},
function(){
$(x).stop(true).fadeTo("slow", 0);
$(w).stop(true).delay().animate({color:col2});
$(y).stop(true).animate({color: col3});
setTimeout(function(){$(y).css("text-shadow", tsh2);},100);}
);
};
edit I've added a plugin which allows .animate({color}) to work. These lines are working fine.
Thanks for the above comments and help. Looking at this again in the morning when I wasn't tired it became clearer. The issue I had was in the first statement, which I thought was working.
Where I was calling $(z).css in the setTimout function this should have been $(fcultys[z]).css. This was a stupid mistake, please see below for my working code.
var fctyhov = function (z) {
$(deptmts[i]).hover(
function(){
$(fcultys[z]).stop(true).animate({color: col1});
setTimeout(function(){$(fcultys[z]).css("text-shadow", tsh1);},100);},
function(){
$(fcultys[z]).stop(true).animate({color: col3});
setTimeout(function(){$(fcultys[z]).css("text-shadow", tsh2);},100);}
);
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With