Trigger event on background image load

后端 未结 4 1554
甜味超标
甜味超标 2021-01-11 11:56

Is there a way, using jQuery, to trigger an event on load of a CSS background image?

4条回答
  •  爱一瞬间的悲伤
    2021-01-11 12:11

    I found that the problem with IE is cache: http://www.witheringtree.com/2009/05/image-load-event-binding-with-ie-using-jquery/

    so you could try this:

    $(”).attr({src: src + ‘?random=’ + (new Date()).getTime()}).load(function (){
      //custom code here....
    });
    

提交回复
热议问题