tttyyy

来源:互联网 发布:徐一叉 知乎 编辑:程序博客网 时间:2024/06/06 03:43

<!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 type="text/css">
*{ margin:0px; padding:0px;}
#tabWarp{ width:400px; height:300px; border:1px solid #ccc; margin:10px auto;}
#tabMenu{ width:400px; height:25px; overflow:hidden; border-bottom:1px solid #ccc; margin-top:5px;}
#tabMenu ul li{ width:80px; float:left; list-style:none; font-size:12px; line-height:25px; height:25px; text-align:center; color:#0066CC; cursor:pointer; border-left:1px solid #ccc; border-right:1px solid #ccc; border-top:1px solid #ccc; margin:0px 5px;}
#tabMenu ul li.curent{ font-size:13px; background:#FBF5E1; font-weight:bold; color:#FF6600;}
#tabContent{ width:390px; height:360px; padding:5px; font-size:12px;}
#tabContent .hide{ display:none;}
</style>
</head>
<body>
<div id="tabWarp">
   <div id="tabMenu">
       <ul>
          <li class="curent">1111</li>
          <li>2222222</li>
          <li>3333333333</li>
          <li>4444444</li>
       </ul>
   </div>
   <div id="tabContent">
      <div>
         <p>11111111的内容</p>
      </div>
      <div class="hide">
         <p>222222的内容</p>
      </div>
      <div class="hide">
         <p>333333333的内容</p>
      </div>
      <div class="hide">
         <p>444444444的内容</p>
      </div>
   </div>
</div>

<script>
  function fgTab(tabNav,tabBody){
    var tabMenu=document.getElementById(tabNav);
    var tabTitle=tabMenu.getElementsByTagName('li');
    var tabContent=document.getElementById(tabBody);
    var tabBody=tabContent.getElementsByTagName('div');
    function switchTab(i){
      tabTitle[i].onmouseover=function(){
        for(j=0; j<tabTitle.length; j++){
    tabTitle[j].className=j===i?"curent":"";
    tabBody[j].style.display=j===i?"block":"none";
        }
       
      }
    }
    for( i=0; i<tabTitle.length; i++){
      switchTab(i);
    }
  }
  function out(){
    return i + '<br/>'+j;
  }
</script>
<script>
  fgTab('tabMenu','tabContent');
</script>
</body>
</html>

原创粉丝点击