標籤頁效果

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");
  });
 });
});

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章