jQuery or Javascript check if image loaded

后端 未结 5 1347
一整个雨季
一整个雨季 2020-11-27 18:14

I know there is a lot of these on Stackoverflow but I haven\'t found one that works for me in a recent version of jquery (1.10.2).

I did try:

$(\".lazy

5条回答
  •  情深已故
    2020-11-27 18:45

    I would give the images that require this constraint a class like mustLoad where:

    
    

    and then create a generic image load handler function, such as:

    $('img.mustLoad').on('load',function(){
            /* Fire your image resize code here */
    });
    

    Edit:

    In response to your comments about deprecating .load() above, .load() was deprecated, in favor of .on('load') to reduce ambiguity between the onLoad event and Ajax loading.

提交回复
热议问题