I am trying to create a for loop to manipulate the background of a page in Javascript, I would like to create a fade in effect from rgb(0;0;0) to rgb(255;0;0)
But I got very stuck in the loop, I didn't find a way to pass a variable to the rgb() function.
Here is my Javascript code:
var r;
function change() {
var doc = document.body;
var color;
for(r = 0; r < 256; r++){
color = rgb(r; 0; 0);
doc.style.backgroundColor = color;
}
}
setInterval(change, 100);