Preload images using jquery

后端 未结 3 836
感情败类
感情败类 2021-02-10 08:38

In my web page some images are taking a lot of time to load in IE.So I used this for preloading images in my page.But still the problem persists.Any suggestions?



        
3条回答
  •  独厮守ぢ
    2021-02-10 09:16

    Try out this jQuery plugin: http://farinspace.com/jquery-image-preload-plugin/

    It allows you to grab img elements using a selector and have it preload them. I'm not sure if the images you want to preload are already in the HTML, if they are you might be interested by this plugin as it allows you to do:

    $('#content img').imgpreload(function()
    {
        // this = jQuery image object selection
        // callback executes when all images are loaded
    });
    

    While still allowing you to manually preload images with file names:

    $.imgpreload('/images/a.gif',function()
    {
        // this = new image object
        // callback
    });
    

提交回复
热议问题