HTML代码:
<!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=gb2312" />
<title>无标题文档</title>
<style>
#div1 {
width:200px;
height:200px;
background:red;
}
</style>
<script>
function toColor(color){
var oDiv=document.getElementById("div1");
oDiv.style.background=color;
}
window.onload=function(){
var oInput1=document.getElementById("input1");
var oInput2=document.getElementById("input2");
oInput1.onclick='toColor("green")';
oInput2.onclick=function(){
toColor("yellow");

}}</script>
</head><body>
<input id="input1" type="button" value="变绿"/>
<input id="input2" type="button" value="变黄"/>
<input type="button" value="变红" onclick="toColor('red')"/>
<div id="div1">
</div>
</body>
</html>
三个onclick的反应的不同写法,为什么input1的写法就不行,这里面到底有什么规定?JS函数