博客列表 >TAB切换与自动切换

TAB切换与自动切换

电动机的博客
电动机的博客原创
2019年04月07日 09:20:26913浏览

<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <title>TAB</title>
 <link rel="stylesheet" type="text/css" href="css/style.css">
 <!-- <script type="text/javascript" src="css/jquery-3.3.1.min.js"></script> -->

  
</head>
<body>
   <div id="notice" class="notice">
  <div id="notice-tit" class="notice-tit">
    <ul>
     <li class="select">
      <a href="#">公告</a>
     </li>
     <li>
      <a href="#">规则</a>
     </li>
     <li>
      <a href="#">论坛</a>
     </li>
     <li>
      <a href="#">安全</a>
     </li>
     <li>
      <a href="#">公益</a>
     </li>
    </ul>
  </div>
  <div id="notice-con" class="notice-con">
   <div class="mod" style="display:block">
    <ul>
     <li>
      <a href="#">
       曝范冰冰将参演好莱坞大片《355》曝范冰冰将参演好莱坞大片《355》
      </a>
     </li>
                    <li>
      <a href="#">
       美在台协会首次公开承认有美军进驻
      </a>
     </li>
     <li>
      <a href="#">
       消防员住地一排***祭战友
      </a>
     </li>
     <li>
      <a href="#">
       小米成立新公司经营范围包括房屋租赁
      </a>
     </li>
    </ul>
   </div>
            <div class="mod" style="display:none">
    <ul>
     <li>
      <span>
       [
                              <a href="#">通知</a>
       ]
      </span>
      <a href="#">
                          "滥发"即将换新
      </a>
     </li>
                    <li>
      <span>
       [
                              <a href="#">通知</a>
       ]
      </span>
      <a href="#">
                          比特币严管啦!
      </a>
     </li>
     <li>
      <span>
       [
                              <a href="#">通知</a>
       ]
      </span>
      <a href="#">
                          禁发商品名录!
      </a>
     </li>
                 <li>
      <span>
       [
                              <a href="#">通知</a>
       ]
      </span>
      <a href="#">
                          商品属性限制
      </a>
     </li>
    </ul>
   </div>
   <div class="mod" style="display:none">
    <ul>
     <li>
      <span>
       [
                              <a href="#">聚焦</a>
       ]
      </span>
      <a href="#">
                          金牌卖家再启航
      </a>
     </li>
                    <li>
      <span>
       [
                              <a href="#">功能</a>
       ]
      </span>
      <a href="#">
                          橱窗规则升级啦
      </a>
     </li>
     <li>
      <span>
       [
                              <a href="#">话题</a>
       ]
      </span>
      <a href="#">
                          又爱又恨优惠劵
      </a>
     </li>
                 <li>
      <span>
       [
                              <a href="#">工具</a>
       ]
      </span>
      <a href="#">
                          购后送店铺红
      </a>
     </li>
    </ul>
   </div>
            <div class="mod" style="display:none">
    <ul>
     <li>
      <a href="#">
                          个人重要信息要管牢!
      </a>
     </li>
                    <li>
      <a href="#">
                           卖家防范红包欺诈提醒
      </a>
     </li>
     <li>
      <a href="#">
                            更换收货地址的陷阱!
      </a>
     </li>
                 <li>
                        <a href="#">
                           注意***的技术升级了!
      </a>
     </li>
    </ul>
   </div>
            <div class="mod" style="display:none">
    <ul>
     <li>
      <a href="#">
                          走进无声课堂
      </a>
     </li>
                    <li>
      <a href="#">
                           淘宝之行大众评审赢公益金
      </a>
     </li>
     <li>
      <a href="#">
                            爱心***联合征集
      </a>
     </li>
                 <li>
                        <a href="#">
                           名公益机构淘宝开店攻略
      </a>
     </li>
    </ul>
   </div>
  </div>
 </div>
   <script type="text/javascript">
        var noticeTit=document.getElementById('notice-tit');
        var noticeCon=document.getElementById('notice-con');
        var title=noticeTit.getElementsByTagName('li');
        var con=noticeCon.getElementsByClassName('mod');
        var num=0;
        var timer=null;
        function autoplay(){
            num++;
            if(num==title.length){
             num=0;
            }
            showTab(num)
        }
          function showTab(i){
              for (var j=0;j<con.length;j++) {
               con[j].style.display='none';
               title[j].className='';
              }
              con[i].style.display='block';
              title[i].className='select';
          }

          for(var i=0;i<title.length;i++){
           title[i].index=i;       //指定元素的位置从0开始
           title[i].onmouseenter=function(){
            clearInterval(timer);//清除定时时间
            showTab(this.index);
            num=this.index;
           }
           title[i].onmouseleave=function(){
            timer=setInterval(autoplay,4000)
           }
          }


   </script>
</body>
</html>

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议