p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px "Microsoft YaHei"; color: #2eafa9 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px "Microsoft YaHei"; color: #060606 }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px "Microsoft YaHei"; color: #2b9edb }
span.s1 { color: #596972 }
span.s2 { color: #2b9edb }
span.s3 { color: #d76019 }
span.s4 { color: #000000 }
span.s5 { color: #6b82d9 }
span.s6 { color: #97a700 }
span.s7 { color: #3c7400 }
span.s8 { color: #2eafa9 }
span.s9 { color: #a5b2b9 }
span.s10 { color: #ad5cff }
html部分:
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px "Microsoft YaHei"; color: #2eafa9 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px "Microsoft YaHei"; color: #596972 }
span.s1 { color: #596972 }
span.s2 { color: #2b9edb }
span.s3 { color: #d76019 }
span.s4 { color: #2eafa9 }
span.Apple-tab-span { white-space: pre }
<div id="nav">
<ul>
<li><a href="">导航</a></li>
<li><a href="">导航</a></li>
<li><a href="">导航</a></li>
<li><a href="">导航</a></li>
<li class="selected"><a href="">导航</a></li>
</ul>
</div>
js部分:
<script type ="text/javascript" language ="javascript">
var nav = document.getElementById( "nav");
var links = nav.getElementsByTagName("li" );
var lilen = nav.getElementsByTagName("a" ); //判断地址
var currenturl = document. location.pathname.slice(0, -5);
var last = 0;
for ( var i = 0; i < links.length; i++) {
var linkurl = lilen[i].getAttribute( "href").slice(0,-5);
if (currenturl.indexOf(linkurl) != -1 ) {
last = i;
}
}
links[last].className = "selected"; //高亮代码样式
</script>