添加多个tab,并循环修改tab样式

 <div class="con">
        <ul id="tags">
            <li class="selectTag"><a onclick="selectTag('tagContent0',this)" href="default.aspx"
                target="repfrm">第一周 </a></li>
            <li><a onclick="selectTag('tagContent1',this)" href="OverrideToString.aspx" target="repfrm">
                第二周</a> </li>
            <li><a onclick="selectTag('tagContent2',this)" href="CreateTextBoxList.aspx" target="repfrm">
                第三周</a> </li>
            <li><a onclick="selectTag('tagContent3',this)" href="PromptDialogBox1.aspx" target="repfrm">
                第四周</a> </li>
            <li><a onclick="selectTag('tagContent4',this)" href="ShowFlash.aspx" target="repfrm">
                第五周</a> </li>
            <li><a onclick="selectTag('tagContent5',this)" href="testDoubleY.aspx" target="repfrm">
                第六周</a> </li>
        </ul>

        <script type="text/javascript">
            function selectTag(showContent, selfObj) {
                // 操作标签
                var tag = document.getElementById("tags").getElementsByTagName("li");
                var taglength = tag.length;
                for (i = 0; i < taglength; i++) {
                    tag[i].className = "";
                }
                selfObj.parentNode.className = "selectTag";
            }
        </script>

        <div id="tagContent" style="height: 695px">
            <div class="tagContent selectTag">
                <iframe id="repfrm" width="100%" name="repfrm" height="100%"
                    scrolling="no" src="default.aspx" frameborder="0"></iframe>
            </div>
        </div>
    </div>

原文地址:https://www.cnblogs.com/lingxzg/p/2147689.html