更新时间:2023-10-31 13:09:16
你可能已经知道$(document).ready(...)。你需要的是一个预加载机制;在显示数据之前获取数据(文本或图像或其他)的东西。这可以使网站感觉更专业。
You probably already know about $(document).ready(...). What you need is a preloading mechanism; something that fetches data (text or images or whatever) before showing it off. This can make a site feel much more professional.
看看 jQuery.Preload (还有其他)。 jQuery.Preload有几种触发预加载的方式,并且还提供回调功能(当图像被预加载时,然后显示它)。我已经大量使用它了,效果很好。
Take a look at jQuery.Preload (there are others). jQuery.Preload has several ways of triggering preloading, and also provides callback functionality (when the image is preloaded, then show it). I have used it heavily, and it works great.
这是开始使用jQuery.Preload的简单方法:
Here's how easy it is to get started with jQuery.Preload:
$(function() {
// First get the preload fetches under way
$.preload(["images/button-background.png", "images/button-highlight.png"]);
// Then do anything else that you would normally do here
doSomeStuff();
});