亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

z-blog讓導航突出顯示當前頁鏈接條目

互聯(lián)網   發(fā)布時間:2009-06-06 15:43:18   作者:jb51   我要評論
關鍵字描述:鏈接 當前 顯示 導航 突出 " < .attr this 代碼 z-blog讓導航突出顯示當前頁鏈接條目: 我們的大致思路是這樣的,首先用js給導航部分中當前鏈接項加個區(qū)分的ID,如<li id=“current”>首頁</li>,然后再用CSS定義就完成了
關鍵字描述:鏈接 當前 顯示 導航 突出 " < .attr this 代碼

z-blog讓導航突出顯示當前頁鏈接條目:

我們的大致思路是這樣的,首先用js給導航部分中當前鏈接項加個區(qū)分的ID,如<li id=“current”>首頁</li>,然后再用CSS定義就完成了。

  • setp1 :加入js(jQuery代碼),如下

    原先功能簡單的代碼

    <script type="text/javascript">
    
    $(document).ready(function(){
    
    $("#menu ul>li").each(function() {  //我們假設導航部分的ID為menu,結構是<div id="menu"><ul><li>...
    
        if ($(this).find("a").attr("href")==document.URL){
    
        $(this).attr("id","current")  //給當前頁的<li>加上id="current",如<li id="current">首頁</li>
    
        }
    
    });
    
    });
    
    </script>

    haphic將這一代碼做了完善,此代碼只支持 Z-Blog 模板.

    haphic 完善后的代碼

    <script type="text/javascript">
    
        $("#menu ul>li").each(function() {
    
            if ($(this).find("a").attr("href").toLowerCase() !== str00.toLowerCase()){
    
                if (document.URL.toLowerCase().indexOf($(this).find("a").attr("href").toLowerCase()) !== -1){
    
                    $(this).attr("id","current")
    
                }
    
            }else{
    
                if ($(this).find("a").attr("href").toLowerCase() == document.URL.toLowerCase()){
    
                    $(this).attr("id","current")
    
                }
    
            }
    
        });
    
    </script>
  • setp2 :定義CSS樣式
    #menu ul li#current {
    
     background-color:#fff;
    
     color:#0B1316;
    
    }

    相關文章

    最新評論