HTML中怎样在一个页面实现多个层显示层隐藏
2个回答
展开全部
我的QQ:1402331052,有需要的话加
<html>
<head>
<script language="javascript">
function showA(){
var divAll = document.getElementsByTagName("div");
if(divAll[0].style.display == "block"){
for(var index = 0 ;index<divAll.length;index++){
divAll[index].style.display = "none";
}
}else{
for(var index = 0 ;index<divAll.length;index++){
divAll[index].style.display = "block";
}
}
}
</script>
</head>
<body>
<input type="button" value="change" onclick="showA()"><br><br>
<div style="border:#ff9900 1 solid;display:block;">a</div>
<br>
<div style="border:#ff9900 1 solid">b</div>
<br>
<div style="border:#ff9900 1 solid">c</div>
</body>
</html>
<html>
<head>
<script language="javascript">
function showA(){
var divAll = document.getElementsByTagName("div");
if(divAll[0].style.display == "block"){
for(var index = 0 ;index<divAll.length;index++){
divAll[index].style.display = "none";
}
}else{
for(var index = 0 ;index<divAll.length;index++){
divAll[index].style.display = "block";
}
}
}
</script>
</head>
<body>
<input type="button" value="change" onclick="showA()"><br><br>
<div style="border:#ff9900 1 solid;display:block;">a</div>
<br>
<div style="border:#ff9900 1 solid">b</div>
<br>
<div style="border:#ff9900 1 solid">c</div>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询