【发布时间】:2010-12-13 02:16:01
【问题描述】:
有人可以帮助我了解如何从 random.php 页面预加载图像,以便在第一次加载时它会淡入淡出。目前它有一个丑陋的批量回声,因为它们没有预加载,但是一旦页面已经运行,一旦它在另一个完美之后淡入淡出......
//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");
});
});
}
});
}
【问题讨论】: