img.style.opacity = 0; let timerId = setInterval(() => { img.style.opacity = img.style.opacity * 1 + .1; if(img.style.opacity >= 1)clearInterval(timerId); }, 50);