JS Coding Questions Logo
JS Coding Questions
#169💼 Interview💻 Code

How do you get the image width and height using JS

Advertisement

728x90

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

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

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 84

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
169of476