This is my attempt at writing a dynamic onmouseout event that slowly changes the opacity when the mouse leaves the div. For some reason the recursion and timeout seem to be no working property and the change in opacity is done immediately.
The question: Is there any reasons that setTimeout()
does not work with recursion? Is there a better way to approach this problem?
function hide(id)
{
if (gOpacity > .4)
{
gOpacity -= .1;
document.getElementById(id).style.opacity = gOpacity;
setTimeout(hide(id),1000)
}
else
{
gOpacity = 1.0
}
}