cant change Class after setTimeout???
I'm trying to set a class after a brief delay using the setTimeout function, but when it enters the code it does nothing. I can change the class before this, just not after it????? This a bug or something that's just not possible??
Below is my code:
- $(document).ready(function() {
- $('[id$=fcrTopInfoDiv]').hover(function(){
$(this).removeClass('fcrInfoDiv').addClass('fcrInfoDivNew');
$(this).animate({top:'154px'},{queue:false,duration:400});
$('div.innerFcrDiv').animate({top:'151px'},{queue:false,duration:400});
- }, function(){
$(this).removeClass('fcrInfoDivNew').addClass('fcrInfoDivToggle');
$(this).animate({top:'170px'},{queue:false,duration:300});
setTimeout(function() {
$(this).removeClass('fcrInfoDivToggle').addClass('fcrInfoDivToggle2');
}, 280);
$('div.innerFcrDiv').animate({top:'167px'},{queue:false,duration:300});
-
});
I've
solved this, by referencing the object as
$(
'[id$=fcrTopInfoDiv]'
)
versus
$(this)
and now the class changes as expected