简体   繁体   English

检查图像是否已满载

[英]Check if image is fully loaded

can you help me? 你能帮助我吗?

How can I check if img is fully loaded before set the src with this function below? 在下面使用此功能设置src之前,如何检查img是否已完全加载?

<img class="loadlater" data-src="path/to/image.ext"/>


$(document).ready(function(){
    $(".loadlater").each(function(index, element){
        $(element).attr("src", $(element).attr("data-src"));
    });
});

Thank you 谢谢

One way you could do this is using the onLoad feature: 一种方法是使用onLoad功能:

<img class="loadlater" data-src="path/to/image.ext" onLoad="function()"/>

This will call the function as soon as the element has loaded 这将在元素加载后立即调用该函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM