【技術】點擊切換&自動切換選項卡

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   java   ar   for   2014   

<!DOCTYPE html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>點擊切換和自動切換選項卡</title>
    <style type="text/css">
    *{list-style:none;margin:0;padding:0;overflow:hidden}
    .tab1{width:401px;border-top:#A8C29F solid 1px;border-bottom:#A8C29F solid 1px;margin:50px 200px;}
    .menu{width:400px;background:#eee;height:28px;border-right:#A8C29F solid 1px;border-bottom:#A8C29F solid 1px;}
    li{float:left;width:99px;text-align:center;line-height:28px;height:28px;cursor:pointer;border-left:#A8C29F solid 1px;color:#666;font-size:14px;overflow:hidden}
    .menudiv{width:399px;height:300px;border-left:#A8C29F solid 1px;border-right:#A8C29F solid 1px;border-top:0;background:#fefefe}
    .menudiv div{padding:15px;line-height:28px;}
    .off{background:#E0E2EB;color:#336699;font-weight:bold}
    </style>
    <script type="text/javascript">
    function setTab(name,cursel){
      cursel_0=cursel;
      for(var i=1; i<=links_len; i++){
        var menu = document.getElementById(name+i);
        var menudiv = document.getElementById("con_"+name+"_"+i);
        if(i==cursel){
          menu.className="off";
          menudiv.style.display="block";
        }
        else{
          menu.className="";
          menudiv.style.display="none";
        }
      }
    }
    function Next(){
      cursel_0++;
      if (cursel_0>links_len)cursel_0=1
      setTab(name_0,cursel_0);
    }
    var name_0=‘one‘;
    var cursel_0=1;
    var ScrollTime=3000;//重複持續時間(毫秒)
    var links_len,iIntervalId;
    onload=function(){
      var links = document.getElementById("tab1").getElementsByTagName(‘li‘)
      links_len=links.length;
      for(var i=0; i<links_len; i++){
        links[i].onmouseover=function(){
          clearInterval(iIntervalId);
          this.onmouseout=function(){
            iIntervalId = setInterval(Next,ScrollTime);;
          }
        }
      }
             document.getElementById("con_"+name_0+"_"+links_len).parentNode.onmouseover=function(){
        clearInterval(iIntervalId);
        this.onmouseout=function(){
          iIntervalId = setInterval(Next,ScrollTime);;
        }
      }
      setTab(name_0,cursel_0);
      iIntervalId = setInterval(Next,ScrollTime);
    }
  </script>
</head>
<body>
  <h3>選項卡在自己切換</h3>
  <div class="tab1" id="tab1">
    <div class="menu">
      <ul>
        <li id="one1" onclick="setTab(‘one‘,1)">懶人建站</li>
        <li id="one2" onclick="setTab(‘one‘,2)">點擊看看</li>
        <li id="one3" onclick="setTab(‘one‘,3)">會自動的</li>
        <li id="one4" onclick="setTab(‘one‘,4)">懶人建站</li>
      </ul>
    </div>
    <div class="menudiv">
      <div id="con_one_1"><h4 style="color:red">懶人建站-解放出你的部分寫代碼時間來思考更高層次的設計</h4></div>
      <div id="con_one_2" style="display:none;"><h4 style="color:red">JS代碼,導覽功能表,焦點圖片,網頁特效,廣告代碼,SEO最佳化,建站技巧</h4></div>
      <div id="con_one_3" style="display:none;"><h4 style="color:red">網頁表徵圖,網頁欣賞模板,SEO最佳化和各種建站技巧;</h4></div>
      <div id="con_one_4" style="display:none;"><h4 style="color:red">解放出你的部分寫代碼時間來思考更高層次的設計</h4></div>
    </div>
  </div>

</body>

【技術】點擊切換&自動切換選項卡

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.