2016-08-23 47 views
0

我有這個腳本,以後我會編程來連續更改背景顏色,但由於某種原因它根本不起作用。它不拋出任何錯誤,要麼如何用JS更改網頁的背景顏色?

<html> 
<body id = "BGCOLOR" bgcolor = rgb(0,0,0); > 
<script> 
function ChangeColor(){ 
    document.getElementById("BGCOLOR").bgcolor = "rgb(0,50,0)"; 
} 
ChangeColor(); 
</script> 
</body> 
</html> 
+0

你參考這個http://stackoverflow.com/questions/197748/怎麼辦-I-變化的背景色,與JavaScript的 –

回答

0

朋友試試這個代碼

<html> 
    <body id = "BGCOLOR" bgcolor = rgb(0,0,0); > 
    <script> 
    function ChangeColor(){ 
     document.body.style.backgroundColor = "rgb(0,50,0)"; 
    } 
    ChangeColor(); 
    </script> 
    </body> 
    </html>