html5页面中,点击按钮显示/隐藏DIV层,大侠们帮忙看看下面的代码有什么问题?
想实现点击按钮后,隐藏/显示id=123的DIV层,但以下代码运行后,点击按钮无反应,请高手指点。<!DOCTYPEhtml><html><headlang="en"><...
想实现点击按钮后,隐藏/显示id=123的DIV层,但以下代码运行后,点击按钮无反应,请高手指点。
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>DIV盒子布局</title>
<link rel="stylesheet" type="text/css" href="BoxCss.css">
</head>
<body>
<!--点击隐藏/显示IDV-->
<input type="button" onclick="DivShow()" />
<div id="123" class="bodytop" style="display: none">
<div class="bodytop-content">
</div>
</div>
<div class="bodycenter">
<div class="bodycenter-image"></div>
<div class="bodycenter-subnav"></div>
<div class="bodycenter-content"></div>
</div>
<div class="bodyfooter">
<div class="bodyfooter-content"></div>
<div class="bodyfooter-subnav"></div>
</div>
<script language="JavaScript">
function DivShow()
{
var iDiv = Document.getElementById("123");
if(iDiv)
{
if(iDiv.style.display=="block")
{
iDiv.style.display="none";
}
else
{
iDiv.style.display="block";
}
}
}
</script>
</body>
</html> 展开
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>DIV盒子布局</title>
<link rel="stylesheet" type="text/css" href="BoxCss.css">
</head>
<body>
<!--点击隐藏/显示IDV-->
<input type="button" onclick="DivShow()" />
<div id="123" class="bodytop" style="display: none">
<div class="bodytop-content">
</div>
</div>
<div class="bodycenter">
<div class="bodycenter-image"></div>
<div class="bodycenter-subnav"></div>
<div class="bodycenter-content"></div>
</div>
<div class="bodyfooter">
<div class="bodyfooter-content"></div>
<div class="bodyfooter-subnav"></div>
</div>
<script language="JavaScript">
function DivShow()
{
var iDiv = Document.getElementById("123");
if(iDiv)
{
if(iDiv.style.display=="block")
{
iDiv.style.display="none";
}
else
{
iDiv.style.display="block";
}
}
}
</script>
</body>
</html> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询