<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>DOM样式</title>
</head>
<body>
<button id="hidden">隐藏</button>
<button id="show">显示</button>
<button id="toggle">显示/隐藏</button>
<div id="box"></div>
<script type="text/javascript">
var o=document.getElementById("box");
o.style.width="150px";
o.style.height="150px";
o.style.background="red";
document.getElementById("hidden").onclick=function(){
o.style.display="none";
};
document.getElementById("show").onclick=function(){
o.style.display="block";
};
document.getElementById("toggle").onclick=function(){
var dis=window.getComputedStyle(o,null).display;
if (dis=="block") {
o.style.display="none";
}else{
o.style.display="block";
}
};
</script>
</body>
</html>