下面的javascript代码是用来改变页面背景的颜色,可单击按钮就是没有反应,请高手看下,谢谢!
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>阶段4</title>
<script language="javascript" type="text/javascript">
function change(color){
if(color == "r")
{
document.bgcolor = "#FF0000";
}
else if(color == "b"){
document.bgcolor = "#0000FF";
}
else if(color == "g"){
document.bgcolor = "#00FF00";
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<input type="button" name="button1" id="button1" value="不许碰我" onclick="change('b')" >
</div></td>
<td><div align="center">
<input type="button" name="button2" id="button2" value="警告你别碰我" onclick="change('r')" >
</div></td>
<td><div align="center">
<input type="button" name="button3" id="button3" value="给你点颜色看看" onclick="change('g')" >
</div></td>
</tr>
</table>
</form>
</body>
</html> 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>阶段4</title>
<script language="javascript" type="text/javascript">
function change(color){
if(color == "r")
{
document.bgcolor = "#FF0000";
}
else if(color == "b"){
document.bgcolor = "#0000FF";
}
else if(color == "g"){
document.bgcolor = "#00FF00";
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<input type="button" name="button1" id="button1" value="不许碰我" onclick="change('b')" >
</div></td>
<td><div align="center">
<input type="button" name="button2" id="button2" value="警告你别碰我" onclick="change('r')" >
</div></td>
<td><div align="center">
<input type="button" name="button3" id="button3" value="给你点颜色看看" onclick="change('g')" >
</div></td>
</tr>
</table>
</form>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询