I'm looking for a quick and easy way to preload images with JavaScript. 我正在尋找一種快速簡單的方法來用JavaScript預加載圖像。 I'm using jQuery if that's important. 若是重要的話,我正在使用jQuery。 javascript
I saw this here ( http://nettuts.com... ): 我在這裏( http://nettuts.com ... )看到了: css
function complexLoad(config, fileNames) { for (var x = 0; x < fileNames.length; x++) { $("<img>").attr({ id: fileNames[x], src: config.imgDir + fileNames[x] + config.imgFormat, title: "The " + fileNames[x] + " nebula" }).appendTo("#" + config.imgContainer).css({ display: "none" }); } };
But, it looks a bit over-the-top for what I want! 可是,對於我想要的東西來講彷佛有點太高了! java
I know there are jQuery plugins out there that do this but they all seem a bit big (in size); 我知道那裏有執行此操做的jQuery插件,但它們彷佛都很大(大小); I just need a quick, easy and short way of preloading images! 我只須要一種快速,輕鬆和簡短的預加載圖像方式! jquery