How do I change the background color with JavaScript?

后端 未结 19 2655
春和景丽
春和景丽 2020-11-22 13:59

Anyone know a simple method to swap the background color of a webpage using JavaScript?

19条回答
  •  梦谈多话
    2020-11-22 14:38

    You can change background of a page by simply using:

    function changeBodyBg(color){
        document.body.style.background = color;
    }
    

    Read more @ Changing the Background Color

提交回复
热议问题