<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="div" style="width: 100px;height: 100px;border: 1px green solid;">123</div>
<button>显示</button>
<button>隐藏</button>
<script>
var div = document.getElementById('div');
var btn = document.getElementsByTagName('button');
btn[0].onclick = function(){
div.style.display = "block";
}
btn[1].onclick = function(){
div.style.display = "none";
}
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="div" style="width: 100px;height: 100px;border: 1px green solid;">123</div>
<button>显示</button>
<button>隐藏</button>
<script>
var div = document.getElementById('div');
var btn = document.getElementsByTagName('button');
btn[0].onclick = function(){
div.style.display = "block";
}
btn[1].onclick = function(){
div.style.display = "none";
}
</script>
</body>
</html>