| Background color testing |
|
This is a simple JavaScript example to fade out a background color using function and array... Click to fade out Greenfunction fade(id) { var dom = document.getElementById(id), level = 1; function step () { var h = level.toString(16); dom.style.backgroundColor = '#FF'+h + h + h + h; if (level < 15) { level += 1; setTimeout(step, 100); } } setTimeout(step, 100); } function green(id){ var dom = document.getElementById(id); dom.style.backgroundColor = '#009966'; } |