complete

jQuery or JavaScript: Determine when image finished loading

 ̄綄美尐妖づ 提交于 2019-11-27 04:25:18
问题 How can I detect when an image has finished loading be it from the server or the browser cache? I want to load various images in the same <img/> tag and detect when the loading of a new images has finished. Thank you. 回答1: $('img').on('load', function() { // do whatever you want }); 回答2: The onload document's event will fire only after all the elements, images included, have fully loaded. The onload <img>'s event will fire after the single image have fully loaded. So you can attach a listener