'client width and height always returning 0.75 after image is loaded
Here's my code:
const images = document.getElementsByTagName('img')
for (let i = 0; i < images.length; i++) {
const currentImage = document.getElementById(`${i}`)
currentImage.onload = () => {
const flex = document.getElementById(`${i}`).clientWidth / document.getElementById(`${i}`).clientHeight
console.log(flex)
document.getElementById(`${i}`).style.flex = flex
}
}
And the console.log statement always returns 0.75.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
