Initially when there's no opacity set, the value will be an empty string. You can default it to 1 and it will work. function fadeOutEffect() { var fadeTarget = document.getElementById("target"); var fadeEffect = setInterval(function () { if (!fadeTarget.style.opacity) { fadeTarget.style.opacity = 1; } if (fadeTarget.style.opacity < 0.1) { clearInterval(fadeEffect); }...