How do I change the background color with JavaScript?

后端 未结 19 2287
春和景丽
春和景丽 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:59

    This will change the background color according to the choice of user selected from the drop-down menu:

    function changeBG() {
      var selectedBGColor = document.getElementById("bgchoice").value;
      document.body.style.backgroundColor = selectedBGColor;
    }

提交回复
热议问题