jquery: how to listen to the image loaded event of one container div?

后端 未结 3 652
温柔的废话
温柔的废话 2021-01-03 00:18

I have a container that has some images inside, I want to listen to the event of every image finish loaded.

eg)

<
3条回答
  •  迷失自我
    2021-01-03 00:46

    Using jQuery:

    $('#container img').load(function() {
        alert('image loaded');
    });
    

    Using simple javascript you can use the onload attribute:

    
    

    The function will be:

    function loadImage() {
        alert("image loaded");
    }
    

提交回复
热议问题