JS實戰篇

來源:互聯網
上載者:User

標籤:body   div   one   document   技術   sof   abs   選擇   小學   

實現選項卡的選擇:

 

如下:

代碼如下:

<!DOCTYPE html><html>    <head>        <meta charset="UTF-8">        <title>選項卡的選擇Demo</title>        <style type="text/css">        *{padding:0px;margin: 0px;font:12px normal "microsoft yahei";}        #tabs {width:290px;padding:5px;height:150px;margin:20px;}        #tabs ul{list-style:none;display: block;height:30px;line-height:30px;border-bottom:2px saddlebrown solid;}        #tabs ul li{background:#fff;cursor:pointer;float:left;list-style:none;height:28px;line-height:28px;margin:0px 3px;border:1px solid #aaaaaa;border-bottom:none;display:inline-block;width:60px;text-align: center;}        #tabs ul li.on{border-top:2px solid saddlebrown;border-bottom: 2px solid #fff;}        #tabs div{height:120px;line-height: 25px;border:1px solid #336699;border-top:none;padding:5px;}        .hide{display: none;}    </style>        <script type="text/javascript">            window.onload = function(){             var oTab = document.getElementById("tabs");             var oUl = oTab.getElementsByTagName("ul")[0];             var oLis = oUl.getElementsByTagName("li");             var oDivs= oTab.getElementsByTagName("div");             for(var i= 0,len = oLis.length;i<len;i++){                 oLis[i].index = i;                 oLis[i].onclick = function() {                     for(var n= 0;n<len;n++){                         oLis[n].className = "";                         oDivs[n].className = "hide";                     }                     this.className = "on";                     oDivs[this.index].className = "";                 }             };         }        </script>    </head>    <body>        <div id="tabs">    <ul>        <li class="on">房產</li>        <li>家居</li>        <li>二手房</li>    </ul>    <div>        275萬購昌平鄰鐵三居 總價20萬買一居<br>        200萬內購五環三居 140萬安家東三環<br>        北京首現零首付樓盤 53萬購東5環50平<br>        京樓盤直降5000 中信府 公園樓王現房<br>    </div>    <div class="hide">        40平出租屋大改造 美少女的混搭小窩<br>        經典清新簡歐愛家 90平老房煥發新生<br>        新中式的酷色溫情 66平撞色活潑家居<br>        瓷磚就像選好老婆 衛生間煙道的設計<br>    </div>    <div class="hide">        通州豪華3居260萬 二環稀缺2居250w甩<br>        西3環通透2居290萬 130萬2居限量搶購<br>        黃城根小學學區僅260萬 121平70萬拋!<br>        獨家別墅280萬 蘇州橋2居優惠價248萬<br>    </div></div>    </body></html>

 

JS實戰篇

聯繫我們

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