I have this piece of code and it actually works fine, yet I have a spurious line in there and it won't work without it for some reason.
It picks up the hover color from the css via jquery and animates that hover (between colors) for browsers that dont have css transitions. ( I am using modernizr to detect the feature). The problem is that if I remove the variable declaration var ie8and9dec = quickbarcolorhover;
( which has no other use at all, it's just there to trigger whatever makes this work ) then it will not work at all for IE8 and IE9 ... (so probably just wont work at all as I think all the other browsers I've used don't need this code in the first place).
Does anyone know why this would be the case? It will also work if I replace the declaration with console.log(quickbarcolorhover);
, and that's how I discovered it. I would rather not have this spurious piece of code if I can avoid it.
$(function() {
var quickbar = $(".no-csstransitions #quick-bar a");
quickbarcolor = quickbar.css("color");
quickbar.hover(function () {
if ( $(this).css("color") != quickbarcolor) {
quickbarcolorhover = $(this).css("color");
}
var ie8and9dec = quickbarcolorhover; /* this dec has no purpose but code wont work without it */
$(this).children().css("color", quickbarcolor).animate({ color: quickbarcolorhover } ,400 );
}, function() {
$(this).children().animate({ 'color': quickbarcolor} ,400 )
}
);
});