Hide images until they're loaded

前端 未结 2 1101
终归单人心
终归单人心 2020-12-18 16:01

I got a jQuery script which is dinamically appending data to the \"holder\" at some timeinterval. The data looks like this:

2条回答
  •  时光取名叫无心
    2020-12-18 16:23

    just set the onload property when you add the image.

    var img = new Image();
    img.src = "some url"
    img.onload=function(){$(img).fadeIn(500);}
    document.getElementByID('parent').appendChild(img);
    

    see working example here

提交回复
热议问题