点击显示与隐藏

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css" >
#div1{100px;height:200px;background:#ccc;display:none;}
</style>
<script type="text/javascript">
function showhide()
{
var oDiv=document.getElementById("div1");
if(oDiv.style.display=="block")
{
oDiv.style.display="none";
}
else
{
oDiv.style.display="block";
}
}
</script>
</head>

<body>
<input type="button" value="点击显示与隐藏" onclick="showhide();"/>
<div id="div1">

</div>
</body>
</html>

原文地址:https://www.cnblogs.com/ll-taj/p/5173403.html