window.addEventListener('load', function(){ //For img src
var allimages= document.getElementsByTagName('img'); for(var i=0; i<allimages.length; i++) { if (allimages[i].getAttribute('data-src')) { allimages[i].setAttribute('src', allimages[i].getAttribute('data-src')); allimages[i].setAttribute('data-src', '') } } //For Background image var alldivs= document.getElementsByTagName('div'); for(var i=0; i<alldivs.length; i++) { if (alldivs[i].getAttribute('data-src')) { alldivs[i].style.backgroundImage = "url('" + alldivs[i].getAttribute('data-src') + "')"; alldivs[i].setAttribute('data-src', '');} }}, false);
Saturday, 2 February 2019
jQuery, JavaScript, HTML: how to load images after everything else is loaded?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment