Javascript examples for jQuery:Width Height
Jquery .width() returns 0 zero before appending the image to the browser
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.2.js"></script> <script type="text/javascript"> $(window).load(function(){/* w w w .j a v a 2s .c om*/ $("#img").attr("src", "http://www.java2s.com/style/demo/Google-Chrome.png").load( function() { console.log($(this).width() + " is the width of the image :)"); }); }); </script> </head> <body> <img id="img" src="http://www.java2s.com/style/demo/InternetExplorer.png"> <img src="http://www.java2s.com/style/demo/Firefox.png"> </body> </html>