js实现选项卡效果
<!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>无标题文档</title>
<style>
ul{
list-style-type:none;
margin-left:-40px;
position:relative;
}
ul li{
padding:5px;
float:left;
width:80px;
position:relative;
display:block;
border-top-width: 1px;
border-right-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-left-style: solid;
border-bottom-style:none;
margin:0px 2px 0px 0px;;
z-index:2;
}
#L1{
background-color:#9CC;
border-top-color: #F6C;
border-right-color: #F6C;
border-left-color: #F6C;
}
#L2{
background-color:#CC9;
border-color:#309;
margin-left:1px;
}
#L3{
background-color:#FF3;
border-color:#360;
}
#L4{
background-color:#690;
border-color:#360;
}
div{
width:400px;
height:220px;
position:absolute;
margin-top:28px;
z-index:1;
}
#d1{
background-color:#9CC;
border:1px solid #C39;
}
#d2{
background-color:#CC9;
border:1px solid #309;
display:none;
}
#d3{
background-color:#FF3;
border:1px solid #360;
display:none;
}
#d4{
background-color:#690;
border:1px solid #360;
display:none;
}
</style>
<script language="javascript">
//选项卡的个数
var num=4;
function getTab(now){
for(var i=1;i<=num;i++){
if(i==now){
document.getElementById("d"+i).style.display="block";
}else{
document.getElementById("d"+i).style.display="none";
}
}
}
</script>
</head>
<body style="margin:0px;">
<ul>
<li id="L1" onclick="getTab(1)">手机数码</li>
<li id="L2" onclick="getTab(2)">手机数码</li>
相关新闻>>
- 发表评论
-
- 最新评论 更多>>