<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="jquery-3.3.1.js"></script>
<script>
$(document).ready(function(){
var h = $("#im").height();
alert("Hello from ready. Height is " + h);
});
$(window).on("load", function(){
var h = $("#im").height();
alert("Hello from load. Height is " + h);
});
</script>
</head>
<body>
<p class="" id="msg"></p>
<p class="" id="msg2"></p>
<img id="im" src="flower.jpg" alt="">
</body>
</html>
1) The above is my code. When I run this in Chrome 64 (64 bit). The window.load portion gets executed before document.ready.
2) Secondly, based what I have read on these forums and elsewhere on the net, I should not be able to get the image height from document.ready, and yet, it works and I get the same height from both the functions.
Why is this happening?