javascript - Strange behavior when getting element height inline - it takes time to get the right heigh -


i have slider 100 images , want extract height of each of parents (the wrapper) use inline onload event:

<div class="wrap" style="height: 100%">   <img src="<%=i.src%>" style="width: 100%; max-height: 100%" onload="        var maxheight = $(this).parent().height();        console.log(maxheight)">  </div> 

i can correct readings on image height. problem parent .wrap element.
strange thing half of images log right height (almost first half of them log 0 height , other half log correct height) , if wrap javascript inside settimeout function can see more time use more logs correct height until time logs correct. know has timing of load event, time fires shouldn't rendered because i'm trying father's height?
so: 1) why happening?
2) how make work?


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -