亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        javascript動(dòng)態(tài)修改Li節(jié)點(diǎn)值的方法

        字號(hào):


            這篇文章主要介紹了js+css實(shí)現(xiàn)tab菜單切換效果的方法,以實(shí)例形式完整講述了css與js的實(shí)現(xiàn)代碼,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
            本文實(shí)例講述了js+css實(shí)現(xiàn)tab菜單切換效果的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
            index.css如下:
            代碼如下:
            * {
            margin: 0px;
            padding: 0px;
            }
            body {
            width: 600px;
            margin: 0 auto;
            background-color: silver;
            }
            #contanier {
            background-color: yellow;
            width: 600px;height: 400px;
            }
            #tabNavi {
            width: 600px;height: 30px;
            background-color: #00bfff;
            text-decoration: none;
            list-style-type: none;
            }
            #tabNavi li {
            float: left;
            margin-right: 7px;
            background-color: #008b8b;
            color: white;
            cursor: pointer;
            width: 60px;
            height: 28px;
            line-height: 30px;
            text-align: center;
            }
            #content {
            width: 600px;height: 370px;
            background-color: white;
            }
            index.html如下:
            代碼如下:
            <!DOCTYPE html>
            <html xmlns="">
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
            <title>js實(shí)現(xiàn)tab菜單動(dòng)態(tài)切換效果</title>
            <link href="css/index.css" rel="stylesheet" />
            <script type="text/javascript">
            function gel(id) {
            return document.getElementById(id);
            }
            var arr = [
            { "title": "新聞", "content": "這是新聞?lì)l道" },
            { "title": "財(cái)經(jīng)", "content": "這是財(cái)經(jīng)頻道" },
            { "title": "娛樂", "content": "這是娛樂頻道" },
            { "title": "體育", "content": "這是體育頻道" },
            { "title": "汽車", "content": "這是汽車頻道" },
            { "title": "視頻", "content": "這是視頻頻道" },
            { "title": "生活", "content": "這是生活頻道" }
            ];
            window.onload = function() {
            for (var i = 0; i < arr.length; i++) {
            var liNew = document.createElement("li");
            liNew.innerHTML = arr[i].title;
            gel("tabNavi").appendChild(liNew);
            //在這些li上面都綁定點(diǎn)擊事件,就需要給他們每一個(gè)賦一個(gè)屬性(最好是id)
            liNew.setAttribute("id", i);
            liNew.onclick = function () {
            var navs = gel("tabNavi").childNodes;
            //清除所有顏色
            for (var j = 0; j < navs.length; j++) {
            if (navs[j].nodeType == 1) {
            navs[j].style.backgroundColor ="#008b8b";
            }
            }
            this.style.backgroundColor = "red";
            gel("content").innerHTML = arr[this.id].content;
            };
            }
            };
            </script>
            </head>
            <body>
            <div id="contanier">
            <ul id="tabNavi"></ul>
            <div id="content"></div>
            </div>
            </body>
            </html>
            希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。