首先頁(yè)面的DIV 是這樣寫的
<div class="aboutLeft" style="margin-left: 0px; height: 324px;">
<ul class="aboutLeftNav">
<li><a href="/Service/">注冊(cè)會(huì)員</a></li>
<li><a href="/Service/Month.html">月會(huì)員</a></li>
<li><a href="/Service/Year.html">年會(huì)員</a></li>
<li><a href="/Service/SVIP.html">SVIP</a></li>
<li><a href="/Service/Cooperation.html">商務(wù)機(jī)構(gòu)合作</a></li>
<li><a href="/Service/Join.html">私人定制</a></li>
</ul>
</div>
JS代碼:
<script type="text/javascript">
$(function(){
var href=''+window.location+'';
href=href.toLowerCase()
if(href.indexOf("html")>0&&href.indexOf("index")>0){
$(".aboutLeftNav li").eq(0).addClass("currentClass")
}
if(href.indexOf("html")==-1&&href.indexOf("index")==-1){
$(".aboutLeftNav li").eq(0).addClass("currentClass")
}
if(href.indexOf("month")!=-1){
$(".aboutLeftNav li").eq(1).addClass("currentClass")
}
if(href.indexOf("half")!=-1){
$(".aboutLeftNav li").eq(2).addClass("currentClass")
}
if(href.indexOf("year")!=-1){
$(".aboutLeftNav li").eq(3).addClass("currentClass")
}
if(href.indexOf("svip")!=-1){
$(".aboutLeftNav li").eq(4).addClass("currentClass")
}
if(href.indexOf("custom")!=-1){
$(".aboutLeftNav li").eq(5).addClass("currentClass")
}
if(href.indexOf("cooperation")!=-1){
$(".aboutLeftNav li").eq(6).addClass("currentClass")
}
if(href.indexOf("join")!=-1){
$(".aboutLeftNav li").eq(7).addClass("currentClass")
}
if(href.indexOf("app")!=-1){
$(".aboutLeftNav li").eq(8).addClass("currentClass")
}
})
</script>
這種頁(yè)面靜態(tài)JS主要是通過(guò)href獲取到的當(dāng)前url,通過(guò)判斷url里的鏈接來(lái)改變css,這樣就可以做到
靜態(tài)頁(yè)面跳轉(zhuǎn)的高亮顯示了。
遠(yuǎn)近互聯(lián)技術(shù)-劉 整理發(fā)布,希望能對(duì)同是技術(shù)的你有所幫助。
遠(yuǎn)近互聯(lián)專業(yè)提供網(wǎng)站建設(shè)、APP開發(fā)、網(wǎng)站優(yōu)化、外貿(mào)網(wǎng)站SEO、微信運(yùn)營(yíng)的品牌整合營(yíng)銷服務(wù),讓客戶通過(guò)網(wǎng)絡(luò)品牌建立與網(wǎng)絡(luò)傳播提高業(yè)績(jī)。






