<!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=utf-8" />
<title>dfsdf</title>
<script>
function go_to(ao)
{
var d = document.getElementById("tab").getElementsByTagName("div");
var h=d.length;
for(var i=0; i<h;i++)
{
if(ao-1==i)
{
d[i].style.display="block";
}
else{
d[i].style.display="none";
}
}
}
</script>
<style>
/* body */
.bodv_div { width:1000px; background-color:#F99; margin:0 auto;}
.first_div{}
.language_title { width:1000px; height:20px; background-color: #39F}
#tab { width:1000px; height:100px; background-color:#FF3}
#tab h3{float:left; width:120px; height:26px; line-height:26px; margin:0; font-size:12px; cursor:pointer; text-align:center; color:red; background-color:#CCC}
#tab div{display:none;}
#tab .block1{display:block;}
#tab div{ height:60px; width:1000px; background-color:#FC9; clear:both}
</style>
</head>
<body>
<!-- head -->
<!-- body 主体部分 -->
<div class="bodv_div">
<!-- body 第一个tab活动样式板块标题 -->
<div class="language_title">ҳ </div>
<!-- body 第一个tab活动样式板块内容 -->
<div id="tab">
<h3 onclick="go_to(1)">tab_1
</h3>
<h3 onclick="go_to(2)">tab_2
</h3>
<h3 onclick="go_to(3)">tab_3
</h3>
<div class="block1">
aaaaaaaaaaaaaaa
</div>
<div class="block2">
bbbbbbbbbbb
</div>
<div class="block3">
ccccccccccccccc
</div>
</div>
</div>
<!-- body -->
</body>
</html> 如何让上面 id="tab" 这种类似 “多个内容在一个栏目显示的板块” 在页面中多出现几次了。
并且互不干扰 。如果不明白我说什么的 ,可以留下你的qq,很急 谢谢!HTML函数类Go
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>dfsdf</title>
<script>
function go_to(ao)
{
var d = document.getElementById("tab").getElementsByTagName("div");
var h=d.length;
for(var i=0; i<h;i++)
{
if(ao-1==i)
{
d[i].style.display="block";
}
else{
d[i].style.display="none";
}
}
}
</script>
<style>
/* body */
.bodv_div { width:1000px; background-color:#F99; margin:0 auto;}
.first_div{}
.language_title { width:1000px; height:20px; background-color: #39F}
#tab { width:1000px; height:100px; background-color:#FF3}
#tab h3{float:left; width:120px; height:26px; line-height:26px; margin:0; font-size:12px; cursor:pointer; text-align:center; color:red; background-color:#CCC}
#tab div{display:none;}
#tab .block1{display:block;}
#tab div{ height:60px; width:1000px; background-color:#FC9; clear:both}
</style>
</head>
<body>
<!-- head -->
<!-- body 主体部分 -->
<div class="bodv_div">
<!-- body 第一个tab活动样式板块标题 -->
<div class="language_title">ҳ </div>
<!-- body 第一个tab活动样式板块内容 -->
<div id="tab">
<h3 onclick="go_to(1)">tab_1
</h3>
<h3 onclick="go_to(2)">tab_2
</h3>
<h3 onclick="go_to(3)">tab_3
</h3>
<div class="block1">
aaaaaaaaaaaaaaa
</div>
<div class="block2">
bbbbbbbbbbb
</div>
<div class="block3">
ccccccccccccccc
</div>
</div>
</div>
<!-- body -->
</body>
</html> 如何让上面 id="tab" 这种类似 “多个内容在一个栏目显示的板块” 在页面中多出现几次了。
并且互不干扰 。如果不明白我说什么的 ,可以留下你的qq,很急 谢谢!HTML函数类Go
{
var d = document.getElementById(id).getElementsByTagName("div");
}最简单的效果。把div id 传到函数
另外使用jquery的选择更多。