javascript自動切換選項卡效果

來源:互聯網
上載者:User
提示:您可以先修改部分代碼再運行

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><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=1setTab(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><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 >歡迎你來到我們的網站,JS效果大全歡迎您~</h4></div><div id="con_one_2" ><h4 >新聞1+1,快樂屬於您</h4></div><div id="con_one_3" ><h4 >會自動切換的選項卡,很不錯。</h4></div><div id="con_one_4" ><h4 >希望再來,再見!</h4></div></div></div></body></td> </tr></table>
提示:您可以先修改部分代碼再運行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.