Author: YangQingQing
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>demo</title>
<script>
var obj = document.getElementById("div_id");
function hideOrShowEvent(){
var obj= document.getElementById("div_id");
if(obj.style.display=="block"){ //如果是显示则隐藏
obj.style.display="none";
}else{ //如果是隐藏则显示
obj.style.display="block";
}
}
</script>
</head>
<body>
<div id="div_id" style="border:1px solid red;display:block;" > 这里是内容 </div>
<button type="button" onclick=hideOrShowEvent()> 点击隐藏或显示 </button>
</body>
</html>