<!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="变绿"οnclick="setColor('green')";/>
<input type="button" value="变黄"οnclick="setColor('yellow')";/>
<input type="button" value="变红"οnclick="setColor('red')";/>
<input type="button" value="变宽"οnclick="setStyle('width','400px')";/>
<input type="button" value="变高"οnclick="setStyle('height','400px')";/>
<input type="button" value="变绿"οnclick="setStyle('background','green')";/>
<div id="div3"> </div>
</body>
<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="变绿"οnclick="setColor('green')";/>
<input type="button" value="变黄"οnclick="setColor('yellow')";/>
<input type="button" value="变红"οnclick="setColor('red')";/>
<input type="button" value="变宽"οnclick="setStyle('width','400px')";/>
<input type="button" value="变高"οnclick="setStyle('height','400px')";/>
<input type="button" value="变绿"οnclick="setStyle('background','green')";/>
<div id="div3"> </div>
</body>
</html>