<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.div1{
width: 10px;
height: 100px;
border:1px solid red;
}
</style>
</head>
<body>
<input type="button" value="变红" onclick="show('background','red');">
<input type="button" value="变高" onclick="show('width','100px');">
<input type="button" value="变宽" onclick="
show('height','200px');">
<div class="div1"></div>
<script>
//odiv.style.property是修改行间样式
//之后在修改样式ClassName的值不会改变
function show(name,value){
var div1=document.getElementsByClassName('div1')[0];
div1.style[name]=value;
}
</script>
</body>
</html>