函数传参

<!DOCTYPE html>
<html>
<style>
#div3 {width: 200px;height:200px;background:red;}
</style>
<script>
function setColor(color)
        {             
var odiv=document.getElementById('div3')
            odiv.style.background=color;
        }
function setStyle(name,value)
        {
            var odiv=document.getElementById('div3')
            odiv.style[name]=value;
        }
</script>
<body>


<input type="button" value="变绿"onclick="setColor('green')";/>
<input type="button" value="变黄"onclick="setColor('yellow')";/>
<input type="button" value="变红"onclick="setColor('red')";/>
<input type="button" value="变宽"onclick="setStyle('width','400px')";/>
<input type="button" value="变高"onclick="setStyle('height','400px')";/>
<input type="button" value="变绿"onclick="setStyle('background','green')";/>
<div id="div3"> </div>
</body>

</html>

函数传参