点击显示与隐藏

<!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{width: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>

posted @ 2016-01-31 15:46  天--安静  阅读(132)  评论(0编辑  收藏  举报