zoukankan      html  css  js  c++  java
  • 母版页导航栏选中解决方案

    html代码:

    <div id="nav_content">
               <ul>
                   <li id="default"><a href="default.html">首页</a></li>
                   <li><a href="saleCar.html">我要卖车</a></li>
                   <li><a href="buyCar.aspx">我要买车</a></li>
                   <li><a href="storeFront.aspx">直营网点</a></li>
                   <li id="test"><a href="login.aspx">会员专区</a></li>
                   <li><a href="intro.aspx">走近安美途</a></li>
                   <li><a href="recruit.aspx">人员招聘</a></li>
                   <li><a href="contact.aspx">联系我们</a></li>
               </ul>
           </div>

    js代码:

    <script type="text/javascript">
                var ah = document.getElementById('nav_content').getElementsByTagName('a');
                        for (i = 0; i < ah.length; i++) {
                            if (window.location.href.indexOf(ah[i]) >= 0) {
                                ah[i].parentNode.className = "selected";
                            }

                        }

                        if (window.location.href.indexOf("DetailInfo.aspx") >= 0 || window.location.href.indexOf("CompareProducts.aspx") >= 0 || window.location.href.indexOf("buyCarFlow.aspx") >= 0 || window.location.href.indexOf("replace.aspx") >= 0) {
                            ah[2].parentNode.className = "selected";
                        }
        </script>

  • 相关阅读:
    jqmodal遮罩层的实现
    让Editplus和SVN集成
    asp.net很有用的字符串操作类
    TCP socket编程
    Adroid: ProgressBar 的使用
    在想的事情......
    I'm new to CNBlogs!
    压力
    开心工作
    feature
  • 原文地址:https://www.cnblogs.com/wuchao/p/2696643.html
Copyright © 2011-2022 走看看