当前位置:编程学习 > C/C++ >>

当前页导航选中

[css]
这是CSS样试 
[css]
[css] 
.dh_nav_l{ width:480px; height:29px; padding-left:5px; float:left;} 
ul{list-style:none; padding:0; margin:0;} 
.dh_nav_l li{ width:74px; height:29px; float:left; margin-right:5px;  text-align:center; line-height:29px;} 
 
.dh_nav_l a{ font-family:微软雅黑,Arial, Helvetica, sans-serif; font-size:14px; background:#0066CC; display:block;} 
.dh_nav_l a:link{ font-size:14px; font-family:微软雅黑,Arial,Helvetica,sans-serif; color:#000; text-decoration:none;}  
.dh_nav_l a:visited{ font-size:14px; color:#000000; font-family:微软雅黑,Arial,Helvetica,sans-serif;  text-decoration:none;}  
.dh_nav_l a:hover{ background:#000000; font-size:14px; font-weight:bold; font-family:微软雅黑,Arial,Helvetica,sans-serif; color:#048585;} 
 
.dh_nav_y a{ background:#000000; font-size:14px; font-weight:bold; font-family:微软雅黑,Arial,Helvetica,sans-serif; } 
.dh_nav_y a:link{color:#048585; text-decoration:none;} 
.dh_nav_y a:hover{color:#048585; text-decoration:none;} 
.dh_nav_y a:visited{color:#048585; text-decoration:none;} 
这是JS
[javascript] 
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> 
<script type="text/javascript"> 
window.onload=function() 

     setMenuBackground(); 

 
 
</script> 
<script type="text/javascript"> 
 
function setMenuBackground() 

     var url = document.URL;//取得当前页的URL 
     
     if(/index/.test(url.toLowerCase()))   //正则查找在url地址中是否有当前页 
     { 
         $("#a_menu").addClass("dh_nav_y"); 
    }else if(/header/.test(url.toLowerCase())) 
    { 
         $("#b_menu").addClass("dh_nav_y"); 
    }else if(/music/.test(url.toLowerCase())) 
    { 
         $("#c_menu").addClass("dh_nav_y"); 
    }else if(/keji/.test(url.toLowerCase())) 
    { 
         $("#d_menu").addClass("dh_nav_y"); 
    }else if(/guonei/.test(url.toLowerCase())) 
    { 
         $("#e_menu").addClass("dh_nav_y"); 
    }else if(/yule/.test(url.toLowerCase())) 
    { 
         $("#f_menu").addClass("dh_nav_y"); 
    } 

</script> 
这是HTML
[html] 
<div class="dh_nav_l"> 
        <ul> 
            <li id="a_menu" ><a href="index.html">首 页</a></li> 
            <li id="b_menu" ><a href="header.html">儿 童</a></li> 
            <li id="c_menu" ><a href="music.html">音乐MV</a></li> 
            <li id="d_menu" ><a href="keji.html">国 内</a></li> 
            <li id="e_menu" ><a href="guonei.html">娱 乐</a></li> 
            <li id="f_menu" ><a href="yule.html">科 技</a></li> 
        </ul> 
    </div> 
这里是上面调用的jquery-1.4.1.min.js

[javascript] 
(function(z,v){function la(){if(!c.isReady){try{r.documentElement.doScroll("left")}catch(a){setTimeout(la,1);return}c.ready()}}function Ma(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,i){var j=a.length;if(typeof b==="object"){for(var n in b)X(a,n,b[n],f,e,d);return a}if(d!==v){f=!i&&f&&c.isFunction(d);for(n=0;n<j;n++)e(a[n],b,f?d.call(a[n],n,e(a[n],b)):d,i);return a}return j? 
e(a[0],b):null}function J(){return(new Date).getTime()}function Y(){return false}function Z(){return true}function ma(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function na(a){var b,d=[],f=[],e=arguments,i,j,n,o,m,s,x=c.extend({},c.data(this,"events").live);if(!(a.button&&a.type==="click")){for(o in x){j=x[o];if(j.live===a.type||j.altLive&&c.inArray(a.type,j.altLive)>-1){i=j.data;i.beforeFilter&&i.beforeFilter[a.type]&&!i.beforeFilter[a.type](a)||f.push(j.selector)}else delete x[o]}i=c(a.target).closest(f, 
a.currentTarget);m=0;for(s=i.length;m<s;m++)for(o in x){j=x[o];n=i[m].elem;f=null;if(i[m].selector===j.selector){if(j.live==="mouseenter"||j.live==="mouseleave")f=c(a.relatedTarget).closest(j.selector)[0];if(!f||f!==n)d.push({elem:n,fn:j})}}m=0;for(s=d.length;m<s;m++){i=d[m];a.currentTarget=i.elem;a.data=i.fn.data;if(i.fn.apply(i.elem,e)===false){b=false;break}}return b}}function oa(a,b){return"live."+(a?a+".":"")+b.replace(/\./g,"`").replace(/ /g,"&")}function pa(a){return!a||!a.parentNode||a.parentNode.nodeType=== 
11}function qa(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var f=c.data(a[d++]),e=c.data(this,f);if(f=f&&f.events){delete e.handle;e.events={};for(var i in f)for(var j in f[i])c.event.add(this,i,f[i][j],f[i][j].data)}}})}function ra(a,b,d){var f,e,i;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&a[0].indexOf("<option")<0&&(c.support.checkClone||!sa.test(a[0]))){e=true;if(i=c.fragments[a[0]])if(i!==1)f=i}if(!f){b=b&&b[0]?b[0].ownerDocument||b[0]:r;f=b.createDocumentFragment(); 
c.clean(a,b,f,d)}if(e)c.fragments[a[0]]=i?f:1;return{fragment:f,cacheable:e}}function K(a,b){var d={};c.each(ta.concat.apply([],ta.slice(0,b)),function(){d[this]=a});return d}function ua(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var c=function(a,b){return new c.fn.init(a,b)},Na=z.jQuery,Oa=z.$,r=z.document,S,Pa=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,Qa=/^.[^:#\[\.,]*$/,Ra=/\S/,Sa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Ta=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,O=navigator.userAgent, 
va=false,P=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,Q=Array.prototype.slice,wa=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(

补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,