运行 ❯
获取您
的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #myDIV { width: 300px; height: 300px; background-color: coral; color: white; } </style> </head> <body> <h1>Change background-color with JavaScript</h1> <p>Click the "Try it" button to set the background-color property of the DIV element to "lightblue":</p> <button onclick="myFunction()">Try it</button> <div id="myDIV"> <h1>Hello</h1> </div> <script> function myFunction() { document.getElementById("myDIV").style.backgroundColor = "lightblue"; } </script> </body> </html>