This is a problem with closing. By the time the function starts, i already in endOpacity . This will work by creating another closure:
function SetOpacityTimeout(eID, opacity, timer){ setTimeout(function() {SetOpacity(eID, opacity);}, timer * 30); } function fade(eID, startOpacity, endOpacity){ var timer = 0; if (startOpacity < endOpacity) { for (var i = startOpacity; i <= endOpacity; i++) { SetOpacityTimeout(eID,i,timer); timer++; } } }
Kobi Jan 31 '10 at 12:16 2010-01-31 12:16
source share