jQuery check if image is loaded

前端 未结 2 487
旧巷少年郎
旧巷少年郎 2021-01-21 08:01

I need help with the following code which doesn\'t work:

var timeoutID=0;
var currentImage=0;//first image is position 0 in arrImages array
var arrImages=[bla bla bla         


        
相关标签:
2条回答
  • 2021-01-21 08:34

    If I remember correctly the image gets the width and height when it gets loaded. So I guess you could check the width if the image. And as long as that is 0 the image is not loaded.

    0 讨论(0)
  • 2021-01-21 08:39

    'complete' is for native javascript object. so you should get javascript object from jQuery. like,

    $('#myImg')[0].complete
    

    or

    $('#myImg').get(0).complete
    
    0 讨论(0)
提交回复
热议问题