用jquery 实现起来超级简单
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(function() {
$(".btn1").click(function(){
$("div").toggle();
});
});
</script>
</head>
<body>
<div>我是div.</div>
<button class="btn1">Toggle</button>
</body>
</html>