[英]How do you change the background color of an webpage with JS?
I have this script that here that I'll program later to continously change the background color, but for some reason it does not work at all. 我有这个脚本,稍后我将在这里编程以不断更改背景色,但是由于某种原因它根本无法工作。 It's not throwing any errors either
也没有抛出任何错误
<html>
<body id = "BGCOLOR" bgcolor = rgb(0,0,0); >
<script>
function ChangeColor(){
document.getElementById("BGCOLOR").bgcolor = "rgb(0,50,0)";
}
ChangeColor();
</script>
</body>
</html>
document.body.style.backgroundColor = "red";
有关更多参考,请访问http://www.w3schools.com/jsref/prop_style_backgroundcolor.asp
friend try this code 朋友试试这个代码
<html>
<body id = "BGCOLOR" bgcolor = rgb(0,0,0); >
<script>
function ChangeColor(){
document.body.style.backgroundColor = "rgb(0,50,0)";
}
ChangeColor();
</script>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.