javascript - How to apply original style on jQuery mouseout -
i have applied fadeout affect on background image. how apply original style on mouseout?
jsfiddle: http://jsfiddle.net/kevinorin/h6q3j/
jquery('.square-section').mouseover(function(){ jquery(this).fadeto('slow',0.3, function(){ jquery(this).css('background-image', 'url(' + $img + ')'); }).fadeto('slow',1); });
you not using $img variable
in first place .. callback function not required in first..
the callback function might have been on here if changing image completely.
jquery('.square-section').hover(function(){ jquery(this).fadeto('slow',0.3); }, function() { jquery(this).fadeto('slow',1); });
if want swap 2 different images can try approach
jquery('.square-section').hover(function(){ jquery(this).fadeto('slow', 0.3, function() { jquery('.square', this).removeclass('square-chess').addclass('square-chart'); jquery(this).fadeto('fast', 1); }); }, function() { jquery(this).fadeto('fast', 0.3, function() { jquery('.square', this).removeclass('square-chart').addclass('square-chess'); jquery(this).fadeto('fast', 1); }); });
jquery('.square-section').hover(function () { jquery('.square', this).removeclass('square-chess').addclass('square-chart'); }, function () { jquery('.square', this).removeclass('square-chart').addclass('square-chess'); });
Comments
Post a Comment