1

can you help me?

How can I check if img is fully loaded before set the src with this function below?

<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

Krip
  • 11
  • 2

1 Answers1

0

One way you could do this is using the onLoad feature:

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

This will call the function as soon as the element has loaded

Abed A.H.
  • 11
  • 1