点击变色

来源:互联网 发布:平面广告制作软件 编辑:程序博客网 时间:2024/05/17 01:33
<!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>changcolor</title>
<script language="javascript">
function chang(){
var color;
color=document.forms.color.value;
switch(color)
{ case "red":
document.bgColor="red";break;
case "green":
document.bgColor="green";break;
case "white":
document.bgColor="white";break;
case "black":
document.bgColor="black";break;
case "yellow":
document.bgColor="yellow";break;
case "blue":
document.bgColor="blue";break;
case "pink":
document.bgColor="pink";break;
default:
alert("请选择背景色");
}
}
</script>
</head>


<body>
<center>
<form name="forms">
<select name="color">
<option>--请选择颜色--</option>
<option value="red">红色</option>
<option value="green">绿色</option>
<option value="white">白色</option>
<option value="black">黑色</option>
<option value="yellow">黄色</option>
<option value="blue">蓝色</option>
<option value="pink">粉红</option>
</select>
<input  type="button" name="button" value="变变" onclick="chang()"/>
</form>
</center>
</body>

</html>



0 0