本文实例讲述了jQuery预加载图片常用方法。分享给大家供大家参考。具体如下:
方法1:
$.preloadImages = function() { for (var i = 0; i<arguments.length; i++) { img = new Image(); img.src = arguments[i]; }}$.preloadImages ( "path_to_image_array", "path_to_image_array", "path_to_image_array");
方法2:
// JQUERY WAY TO PRELOAD IMAGES// DOES NOT NEED TO BE IN DOCUMENT READY$.preloadImages = function(){ for(var i = 0; i<arguments.length; i++) { img = new Image(); img.src = arguments[i]; }}$.preloadImages("path/to/image/1","path/to/image/2","path/to/image/3");
希望本文所述对大家的jQuery程序设计有所帮助。
新闻热点
疑难解答