html - PHP: Don't load images until div is expanded? -
html - PHP: Don't load images until div is expanded? -
on site, have updates section, groups updates (galleries) own div. each div loaded hidden. take section, , expands show new galleries.
that works fine. however, loads images on page load, causes hr glass linger longer like. there way create image load after div made visible?
edit:
went with:
$(function() { $('.collapse img').attr('src', function(index, src) { homecoming this.getattribute('data-src'); }); }); collapse div name has images in it. how can changed alter images in current div? collapsed divs have same name. however, when expanded, want load images in 1 div. right loads images in collapsed div 1 time expand 1 of them.
your divs should not contain images @ startup. can load images via javascript if user expands div.
example:
function expanddiv(idofdivelement) { divobj = document.getelementbyid(idofdivelement); var imageobj = document.createelement('img'); imageobj.setattribute('src', 'path/example_image.jpg'); divobj.appendchild(imageobj); // expand div code here } you advance function , add together sec parameter image url. or array / comma seperated string if want load multiple images.
php html expand
Comments
Post a Comment