有人可以帮助我理解如何从random.php页面预加载图像,因此第一次加载它时就会像应该那样淡入。目前它有一个丑陋的散装回声,因为他们不预装但一旦页面已经被运行一次,它的另一完全消失后,上...从Ajax调用预加载图像
//Loop through the images and print them to the page
for (var i=0; i < totalBoxes; i++){
$.ajax({
url: "random.php?no=",
cache: false,
success: function(html) {
// following line I originally suggested, but let's make it better...
//$('#bg').append(html).fadeIn('slow');
// also note the fine difference between append and appendTo.
var $d = $(html).hide().appendTo('#bg').fadeIn('slow');
$('img', $d).hover(function() {
var largePath = $(this).attr("rel");
$(this).fadeOut("slow", function() {
$(this).attr({ src: largePath }).fadeIn("slow");
});
});
}
});
}
大有用的插件:
你可以在你的代码通过做这样的事情,然后用这个! +1 – alex 2010-06-15 04:10:47
嘿伙计,我用你的插件,它至少引起了一些意想不到的行为。看到这个问题:http://stackoverflow.com/questions/3050111/attention-javascript-gurus-need-a-hand-with-setinterval – alex 2010-06-16 01:43:10