js问题 bgcolor属性
来源:百度知道 编辑:UC知道 时间:2024/09/13 02:52:17
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>变化颜色</title>
<script type="javascript">
function change(color){
document.bgColor=color;
}
</script>
</head>
<body>
<h2>变颜色</h2>
<font size="4">
<span onmouseover="change('red')">变红色</span>|
<span onmouseover="change('blue')">变蓝色</span>|
<span onmouseover="change('yellow')">变黄色</span>
</font>
</body>
</html>
为什么变不了颜色?!!
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>变化颜色</title>
<script type="javascript">
function change(color){
document.bgColor=color;
}
</script>
</head>
<body>
<h2>变颜色</h2>
<font size="4">
<span onmouseover="change('red')">变红色</span>|
<span onmouseover="change('blue')">变蓝色</span>|
<span onmouseover="change('yellow')">变黄色</span>
</font>
</body>
</html>
为什么变不了颜色?!!
<script type="javascript">
function change(color){
document.bgColor=color;
}
</script>
错误
应该为
<script type="text/javascript">
可以变的啊
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>变化颜色</title>
<script>
function change(color){
document.bgColor=color;
}
</script>
</head>
<body>
<h2>变颜色</h2>
<font size="4">
<span onmouseover="change('red')">变红色</span>|
<span onmouseover="change('blue')">变蓝色</span>|
<span onmouseover="change('yellow')">变黄色</span>
</font>
</body>
</html>