js簡易日曆

來源:互聯網
上載者:User

標籤:

js簡易日曆中設計的知識點:選項卡切換   數組    innerHTML  串連符

與選項卡的區別:div的個數不同

串連符中需要注意的:(優先順序)

"abc"+12+3+"def"               結果:abc123def

"abc"+(12+3)+"def"            結果:abc15def

html代碼:

<body>        <div class="contain">            <ul id="tab" class="clearFix">                <li>1月</li>                <li>2月</li>                <li>3月</li>                <li>4月</li>                <li>5月</li>                <li>6月</li>                <li>7月</li>                <li>8月</li>                <li>9月</li>                <li>10月</li>                <li>11月</li>                <li>12月</li>            </ul>            <div id="content">                <h2>1月活動</h2>                <p>去滑雪啦,哈哈</p>            </div>        </div>    </body>

css代碼:

<link rel="stylesheet" type="text/css" href="css/public.css"/><style type="text/css">    .contain{width: 240px;margin: 0 auto;margin-top: 100px;}    #tab{width: 240px;}    #tab li{float: left;width: 40px;height: 60px;line-height:60px;margin: 10px;text-align:center;background: #dbdbdb;cursor: pointer;}    #tab li.active{background: #f60;color: #fff;}    #content{margin: 10px;width: 200px;min-height: 100px;padding:10px;background: #999;}</style>

js代碼:

<script type="text/javascript">            window.onload=function(){                var oTab=document.getElementById("tab");                var aLi=oTab.getElementsByTagName("li");                var oDiv=document.getElementById("content");                var arr=[‘去滑雪啦,哈哈‘,‘222‘,‘333‘,‘444‘,‘555‘,‘666‘,‘777‘,‘888‘,‘999‘,‘100‘,‘101‘,‘102‘];                for(var i=0;i<aLi.length;i++){                    aLi[i].index=i;                    aLi[i].onmouseover=function(){                        for(var i=0;i<aLi.length;i++){                            aLi[i].className="";                        }                        this.className="active";                        oDiv.innerHTML=‘<h2>‘+(this.index+1)+‘月活動</h2><p>‘+arr[this.index]+‘</p>‘;                    }                }            }</script>

效果如下:

 

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.