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); }); 

check fiddle

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);     }); }); 

fiddle 2 images

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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -