javascript標籤頁切換功能(極簡代碼)

來源:互聯網
上載者:User

標籤:內容   rip   type   gpo   get   post   order   lang   pad   

 1 <!doctype html> 2 <html lang="en"> 3 <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script> 4 <head> 5     <meta charset="UTF-8"> 6     <title>boss愛國</title> 7 <style> 8     body{background:#ececec;margin:0;} 9     #test{width:100%;height:40px;background:#fff;}10     .btn{padding:11px 16%;float:left;list-style:none;}11     .focus{border-bottom:1px solid #269be8; color:#269be8;}12     .line{width: 1px;text-indent: -10000px;border-right: 1px solid #ccc;height: 28px;float:left;margin-top:3px;}13     .content{padding:4%;display:none;}14 </style>15 </head>16 <body>17     <div id=‘test‘>18             <li id=‘btn_1‘ onclick=‘switchTab(1)‘ style=‘padding:11px 16%;float:left;list-style:none;‘ class=‘focus‘>毛**語錄</li>    19             <li class=‘line‘>|</li>20             <li id=‘btn_2‘ class=‘btn‘ onclick=‘switchTab(2)‘ style=‘padding:11px 16%;float:left;list-style:none;‘>共**宣言</li>21     </div>22     <div id=‘con_1‘ class=‘content‘ style=‘display:block‘>23         《毛**語錄》,是二十世紀六十年代初編輯出版、風靡全國乃至世界的毛**主席名言警句選編本,發行量達50億冊,位居世界第二。因為最流行的版本用紅色封麵包裝,又是紅色領袖的經典言論,所以文化大革命中被普遍稱為“紅寶書”。24     </div>25     <div id=‘con_2‘ class=‘content‘>26         《共**宣言》,是卡爾·馬克思和費裡德裡希·恩格斯為共產主義者同盟(Communist League)起草的綱領,國際共產主義運動第一個綱領性文獻,闡述了階級矛盾對人類曆史的影響,...27     </div>28 </body>29     <script type="text/javascript">30         function switchTab(n){31             for(var i = 1; i <= 2; i++){32                     document.getElementById("btn_" + i).className = "";                //先把所有的按鈕的class設為0,33                     document.getElementById("con_" + i).style.display = "none";        //把所有的內容隱藏34             }35             document.getElementById("btn_" + n).className = "focus";                //為點擊的按鈕加上樣式36             document.getElementById("con_" + n).style.display = "block";            //顯示點擊的內容37         }38     </script>39 </html>

 

javascript標籤頁切換功能(極簡代碼)

聯繫我們

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