在我的脚本的开头,我有:
jQuery(function() {
jQuery('img.thumbnail').hide().load( function() {
jQuery('img.thumbnail').fadeIn();
});
});当页面上的缩略图被加载时,它会很好地淡入页面中。但是,当我第二次访问该页面时(当它被缓存时),或者当我在浏览器中按下后退按钮时,图像将保持隐藏状态,并且永远不会出现。我必须手动刷新页面。
我做错了什么?
谢谢。
发布于 2010-02-01 08:38:57
试试这个,因为.load() may not fire on all browsers when fetching from cache
jQuery(function() {
jQuery('img.thumbnail').hide().each(function() {
if (this.complete)
$(this).fadeIn();
else
$(this).load( function() { $(this).fadeIn(); });
});
});发布于 2010-02-01 08:39:14
您是否尝试过将其添加到$(document).ready()语句中?然后,只要页面加载完成,它就会运行。
https://stackoverflow.com/questions/2174033
复制相似问题