How do I change the background color with JavaScript?

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

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

相关标签:
19条回答
  • 2020-11-22 15:02

    Add this script element to your body element, changing the color as desired:

    <body>
      <p>Hello, World!</p>
      <script type="text/javascript">
         document.body.style.backgroundColor = "#ff0000";  // red
      </script>
    </body>

    0 讨论(0)
提交回复
热议问题