InterviewHubPRO
Section Overview
Q173

Question 173 of 521

Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

33%
JavaScript Internals (521 Qs)•Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

How do you get the image width and height using JS

You can programmatically get the image and check the dimensions(width and height) using JavaScript.

javascript
  var img = new Image();
  img.onload = function () {
    console.log(this.width + "x" + this.height);
  };
  img.src = "http://www.google.com/intl/en_ALL/images/logo.gif";