Change background color between red and green every second

前端 未结 10 1198
终归单人心
终归单人心 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:39

    You should definetly read some basic JavaScript tutorial or book. I am also new to JavaScript but some reading has helped. Here http://www.w3schools.com/js/ you can find some good stuff as reference.

    This should do the trick

    
    
        
            
        
    
        
    
    

    If you are going to manipulate the DOM a lot i recommend JQuery

提交回复
热议问题