div.addEventListener('click', () => {
for (let i=1; i<3000; i++) {
setTimeout(() => {
let style = div.clientHeight-1;
style = style + 'px';
div.style.height = style;
},i)
}
})
Why doesn't this code work? I have a div element 500x500 and I try to animate it's height. When I set let style = div.clientHeight - 2;
or to a number bigger than 2, it works, but it doesn't work for 1. What is the problem, and how do I animate the height with JS properly?