Is there a way, using jQuery, to trigger an event on load of a CSS background image?
A:
you could do it like this,
demo
$('<img>').attr('src',function(){
return $('body').css('background-image');
}).load(function(){
alert('background loaded!')
// do triggering here....
});
Reigel
2010-07-19 13:59:38
Would this wait until the image is loaded or until there is a return on the value of the 'background-image' property?
Squirkle
2010-07-19 14:04:38
actually what happened there is it will wait for the image to load... in this case the background image of the body tag...
Reigel
2010-07-19 14:37:48
That's a pretty neat trick. How does it work? I can't figure out what $('<img>') is targeting...
Squirkle
2010-07-19 15:21:46