I am trying to download an image then apply a fade using css background-image
.
I can accomplish this when it is a regular <img src=''/>
like so:
#mainImg {display:none}
var c = $('#mainImg');
$(new Image()).load(function(){
c.fadeIn(300);
}).attr('src', c.attr('src'));
But how can i detect it when it is a css background
?
Here's css using jQuery, but i cant seem to get it like the code above and detect when the download is finished
$('<img/>').attr('src', 'image.png').load(function() {
$('#mainImg').css('background-image', 'url(image.png)');
});
edit this helped out! How can I check if a background image is loaded? thank you @colin