An Interest In:
Web News this Week
- April 28, 2024
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
March 15, 2017 01:56 pm GMT
Original Link: https://css-tricks.com/measuring-image-widths-javascript-carefully/
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:
Tweet
View Full Article