返回顶部

收藏

jQuery 预加载图片

更多

[JavaScript]代码

$.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"
);

[JavaScript]代码

// 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

收藏

0人收藏

支持

0

反对

0

发表评论