我正在使用jquery在加载主内容之前加载预加载图像。问题是,当我点击链接时,加载图像在显示之前至少需要5秒。我希望它能够在内容显示前点击链接立即显示。滞后的jquery预加载器图像
这里是jQuery的;
$(function() {
$("li#tabs.popup a").click(function(e) {
$("#popup").slideDown().addClass('active');
$('#popup').html('<center><img src="images/loader.gif" /></center>');
$('#popup').load('wishlist.php');
$('li#tabs.popup a').removeClass('selected');
$(this).addClass('selected');
e.stopPropagation();
});
});
经过多次的烦躁后,我找到了问题的答案。出于某种原因,将加载程序放在所有其他函数之上会使其加载顺利并立即点击。
因此,而不是上面的代码,我做
$(function() {
$("li#tabs.popup a").click(function(e) {
$('#popup').html('<center><img src="images/loader.gif" /></center>');
$("#popup").slideDown().addClass('active');
$('#popup').load('wishlist.php');
$('li#tabs.popup a').removeClass('selected');
$(this).addClass('selected');
e.stopPropagation();
});
});
现在它只是完美!
你的装载机镜像在哪里设置?也就是loader.gif实际上在被jquery设置之前在页面的任何位置使用? – jammypeach