javascript - Alternative to setTimeout for images -
if want create div high (responsive) image using javascript, resorting settimeout. example might have code this
settimeout(function(){ var $imgheight = $('img').height(); $('.mydiv').height($imgheight); }, 400);
is there alternative this? know imagesloaded plugin, there simpler alternative?
many thanks
you can use load
event know when images loaded:
$('img').on('load', function(){ $('.mydiv').height(this.height); });
though don't see need set divs height. doesn't adjust image height default?
Comments
Post a Comment