How to load images after page loaded?

后端 未结 3 1782
情话喂你
情话喂你 2021-01-01 09:14

I have this code:

            

        
相关标签:
3条回答
  • 2021-01-01 09:51

    Try this:

    $("#m"+id).load("//your link");
    

    You can read more on this on: api.jquery.com/load/

    0 讨论(0)
  • 2021-01-01 09:57

    Check this link

    This plugin loads images / background url after the DOM load event and window load event are triggered.

    Initially the src attribute of the img tag will be set to empty. And the html should contain a data attribute which will contain the image path. The plugin will take care of the rest of things.

    After image loads, the below code will be executed. All these are handled by the plugin

    $('img').attr('src', < data URL with the img path > )
    
    0 讨论(0)
  • 2021-01-01 10:02

    The display: hidden set on your <img> element should be display: none. Also, bear in mind that users visiting your page with JavaScript disabled will never see the image, only the permanent loading message. You should use a gracefully degrading solution instead.

    0 讨论(0)
提交回复
热议问题