javascript - Height of div element returns zero -


does know why height 0 here?

    $(document).ready(function () {                  alert($("#hello").height());      });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <img id="hello" class="browseimg" src="https://udemy-images.udemy.com/course/750x422/64132_926c_10.jpg" />

it because after dom loaded successfully, getting height of image before image loading network.

probably have in load event of image.

$('#hello').load(function() {     alert($("#hello").height()); });   

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -