小白求助:为什么这样实现不了输入颜色后背景颜色的改变?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script language="JavaScript">
function color(c)
{ var a=this.form.text1.value;
if(a=="red" )
{document.bgColor="red";}
else if(a="blue")
{document.bgColor="blue";}
else if(a="yellow")
{document.bgColor="yellow";}
}
</script>
</head>
<body>
<form>
<input type="text" value="请输入颜色" name="text1" />
<input type="button" value="确定" name="button" onclick="color()"/>
</form>
</body>
</html>