JavaScript Height of div element returns zero jquery element height returns 0,element height returns 0,jquery

Does anyone know why the height could be zero 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" />
Answer:1

It is because even after DOM loaded successfully, you are getting the height of the image before even the image loading from network.

Probably you have to do that in load event of image.

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

Delete document.ready function because it's returning the height of element before actually loading it.

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" />
Answer:3

I'm thinking using S3 Amazon for storage (if you guys have better one, don't hesitate to recommend). I could do a normal file upload, but let's say I'm uploading a very large video/music file (...

I'm thinking using S3 Amazon for storage (if you guys have better one, don't hesitate to recommend). I could do a normal file upload, but let's say I'm uploading a very large video/music file (...

  1. google cloud storage multipart upload

I'm trying to select the data that comes from the data base with jQuery, but my problem is that only the first result has a click handler bound to it. Here is the PHP part: <?php $sql = "SELECT ...

I'm trying to select the data that comes from the data base with jQuery, but my problem is that only the first result has a click handler bound to it. Here is the PHP part: <?php $sql = "SELECT ...

We are running a quick javascript function to fill out and save a form to quickly move forward in a workflow (for testing purposes). It's running fine in all browsers except for Firefox - and only on ...

We are running a quick javascript function to fill out and save a form to quickly move forward in a workflow (for testing purposes). It's running fine in all browsers except for Firefox - and only on ...

I want to use jQuery's multiple selectors and set on() on them and then using "$(this)" implement something I need. This should look like this: $(".one, .two, .three").on("someEvent", function () { ...

I want to use jQuery's multiple selectors and set on() on them and then using "$(this)" implement something I need. This should look like this: $(".one, .two, .three").on("someEvent", function () { ...

  1. using this with arrow functions
  2. using this with jquery
  3. using this with a constructor
  4. using this with class jquery
  5. using this with javascript
  6. using this with typescript
  7. using this in java
  8. using this in a sentence
  9. using this in constructor c++
  10. using this in c#
  11. using this to start a sentence
  12. using this in node.js
  13. using this in html
  14. using this in parameter c#
  15. using this in past tense
  16. using this in javascript onclick
  17. using this in lambda java
  18. using this in javascript class
  19. using this in python
  20. using $ this in ajax jquery