html代码
<!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=gbk" />
<link rel="stylesheet" type="text/css" href="css/tab.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/tab.js"></script>
</head>
<body>
<ul>
<li class="labelin">标签1</li>
<li>标签2</li>
<li>标签3</li>
</ul>
<div class="contentin">我是内容1</div>
<div>我是内容2</div>
<div>我是内容3</div>
</body>
</html>
css代码
ul,li {
margin:0px;
padding:0px;
list-style:none;
}
li{
float:left;
background-color:#DCDBD6;
color:white;
padding:1px;
border:2px solid white;
}
div {
clear:left;
background-color:#6E6E6E;
color:white;
width:300px;
height:100px;
display:none;
}
.contentin {
display:block;
}
.labelin {
border:2px solid #6E6E6E;
background-color:#6E6E6E;
}
jquery代码
$(document).ready(function(){
$("li").each(function(index){
$("li").eq(index).mouseover(function(){
$(".labelin").removeClass("labelin");
$(this).addClass("labelin");
$(".contentin").removeClass("contentin");
$("div").eq(index).addClass("contentin");
});
});
});