Detect image load by jQuery

后端 未结 1 637
眼角桃花
眼角桃花 2020-12-18 22:07

I change src of this image on .click event.

There can be loaded more than 20 d

相关标签:
1条回答
  • 2020-12-18 23:04

    You need to attach an event handler for the load event:

    Update 2017:

    $('img').on('load', function() {
        alert('new image loaded: ' + this.src);
    });
    

    Plain JS/DOM:

    imgNode.onload = () => {
        alert('new image loaded: ' + this.src);
    };
    
    0 讨论(0)
提交回复
热议问题