I'm trying to figure out if it's possible to fadeIn a background image of a div, I currently have a function which shows a background image of the relevant div on hover, but the show / hide is a bit harsh I'd like it to fade In / Out instead, can't figure out how to do so though.
Here's my code:
jQuery(document).ready(function(){
jQuery(".thumbnail").hover(function(){
var imgurl = jQuery(this).data("hoverimage");
jQuery(this).css("background-image", "url(" + imgurl + ")");
}, function(){
jQuery(this).css("background-image", "");
});
});
This function simply shows the background image on mouseenter and hides it again on mouseleave, is it at all possible to fadeIn when hovering over the relevant div instead and fadeOut when leaving the div?
background-image
. You need to put a div behind it. – Mooseman