我需要一些帮助,我似乎无法弄清楚如何预加载图像我的下一个按钮在我建立的图像查看器。我从MySQL数据库抓取图像源,并在每次按下下一个按钮时遍历它们。我如何预先加载这些?这里是我的下一个按钮的代码:从jquery预加载图像从MySQL
$("#next").click(function(){
$(h).empty();
var p = <?php echo json_encode($results); ?>;
var start = $("#intabdiv img").attr("class");
var next = p[($.inArray(start, p) + 1) % p.length];
//Checking the ID of thumbnail pictures and determining the id here
var hinext = "../php/admin/portfolio/before/"+next;
$("#intabdiv img").attr('src',hinext);
$("#intabdiv img").attr('class',next);
//Centering image on screen
var h = $("#intabdiv img").width() + 70;
//ww is defined beforehand and is the windows width.
var total = ww - (h/2);
$(".popupbox").css("margin-left", total);
});
“var p”的内部是什么样的?现在很难猜测。 – 2012-03-14 16:10:00
这是一个简单的数组,看起来像这样(image1.jpg,image2.jpg,image3.jpg)。谢谢 – liveandream 2012-03-14 17:41:54