Closure - Set body color and fade to white
Closure - Set body color and fade to white
by Nirvanachain
JavaScript
// Define a function that sets a DOM node's color
// to yellow and then faces it to white.
var fade = function(node) {
var level = 1;
var step = function() {
var hex = level.toString(16); // 16 is hexidecimal in toString method.
node.style.backgroundColor = '#FFFF' + hex + hex;
if (level < 15) {
level += 1;
setTimeout(step, 100);
}
};
setTimeout(step, 100);
};
fade(document.body);