Change background color between red and green every second

前端 未结 10 1232
终归单人心
终归单人心 2020-12-19 16:10

I\'m trying to make a webpage change the background color every one second using JavaScript. I\'m using setTimeout but I can\'t figure out how to get my variabl

10条回答
  •  天涯浪人
    2020-12-19 16:51

    x = 1; assigns x a value of 1, even in an if statement. Use x == 1 in if statements to keep the value of your variable unchanged.

提交回复
热议问题