When i run this code i get an error saying its reading null from .style which dosent make any sense to me because im assigning it an value not reading it.
function colorChange() {
document.body.style.background = "rgb(29, 33, 240);";
}
setInterval(colorChange, 1);
2
Answers
just use this line then you can see your element color has changed….
You need to remove the semicolon after the
rgb
for it to work, as you’re assigning a value, not writing a complete CSS statement. Also, yoursetInterval
isn’t really doing anything (it just perpetually sets the background color to a semi-blue color every millisecond).