有没有办法使用jQuery来触发CSS背景图像的加载事件?
解决方法
你可以这样做,
$('<img>').load(function(){ // make sure to bind the load event BEFORE setting the "src" alert('image loaded'); }).attr('src',function(){ var imgUrl = $('body').css('background-image'); imgUrl = imgUrl .substring(4,imgUrl .length-1); return imgUrl; }).each(function() { // fail-safe for cached images which sometimes don't trigger "load" events if(this.complete) $(this).load(); });