I have created a simple script that changes the background image when hovering over a div. However, I am experiencing a flickering issue where the image briefly turns white before transitioning. I have tried to resolve this problem but have not been successful. Here is the code I am currently using:
$(document).ready(function(){
$('#wrapper').mouseenter(function() {
$("body").css({"background":"url(images/main_background_over.jpg) no-repeat center fixed",
"-webkit-transition":"all 1.0s ease-in-out",
"-moz-transition":"all 1.0s ease-in-out",
"-o-transition":"all 1.0s ease-in-out",
"-ms-transition":"all 1.0s ease-in-out",
"transition":"all 1.0s ease-in-out",
"background-size":"cover"
});
});
$('#wrapper').mouseleave(function() {
$("body").css({"background":"url(images/main_background.jpg) no-repeat center fixed",
"background-size":"cover"
});
});
});
In addition, I am encountering issues with the transition effects in Firefox and Safari. If anyone has a solution for this problem, I would greatly appreciate it.