关于JavaScript函数的传递中的一点小问题
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>函数的参数传递</title>
<style>
#color{
width:200px;
height:200px;
background-color:black;
border:1px solid silver;
}
</style>
</head>
<body>
<input type="button" value="yellow" onclick="changeColor('yellow');">
<input type="button" value="blue" onclick="changeColor('blue');">
<input type="button" value="white" onclick="changeColor('white');">
<div id="color"></div>
<script>
function changeColor(color){
var i=document.getElementById('color');
i.style.background=color;
}
</script>
</body>
</html>
其中注意的是:在js代码中 所传递的颜色参数名color不能同函数中的任何定义变量名相同 因为他们同时为函数内的局部变量