Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
March 15, 2017 01:56 pm GMT

Measuring Image Widths in JavaScript (Carefully!)

Let's say you want to find an <img> on the page and find out how wide it is in JavaScript. Maybe you need to make some choices based on that width (or height, or both) You can definitely do that. The DOM will even give you a variety of dimensions to choose from depending on what you need. There is definitely a catch though.

Here's the image:

<img src="image.jpg" alt="an image">

And here's us selecting it, by finding the first …


Measuring Image Widths in JavaScript (Carefully!) is a post from CSS-Tricks


Original Link: https://css-tricks.com/measuring-image-widths-javascript-carefully/

Share this article:    Share on Facebook
View Full Article

CSS Tricks

A Web Design Community curated by Chris Coyier

More About this Source Visit CSS Tricks