使用Jquery预加载spritesheet
问题描述:
我现在有一个spritesheet我想要做的是预加载spritesheet图像如何使用javascript来解决它。请帮助我。
I am having a spritesheet now what i want to do is to preload the spritesheet images how can i get through it using javascript.Please help me out.
答
这不是HTML5,也不是jQuery特有的。精灵表只是一个图像,因此像任何其他图像一样预加载。也就是说,jQuery方式将是:
This is not HTML5 nor specifically jQuery related. A sprite sheet is just an image, so preload like you would any other image. That said, a "jQuery way" would be:
var $mySprite = $("<img>").attr("src", "myURL");
Voila。