效果
代码
<body>
<input type="button" id="btn" value="样式设置" />
<div id="dv"></div>
<script>
function my(id){
return document.getElementById(id);
}
//凡是css中这个属性是多个单词写法,在js代码中写法是后面单词首字母大写
my("btn").onclick=function(){
my("dv").style.width="200px";
my("dv").style.height="100px";
my("dv").style.backgroundColor="red";
}
</script>
</body>