This example describes the way JavaScript implements the current pager activation. Share to everyone for your reference. Specifically as follows:
HTML section (referenced navigation, no # Instead of links, test can create a few static pages)
<ul id= "NAV" >
<li><a href= "/" > Home </a></li>
<li><a href= "/category/ html-css/">HTML/CSS</a></li>
<li><a href="/category/javascript/">javascript</ a></li>
<li><a href= "/category/seo/" >SEO</a></li>
<li><a href= "/category/front-end/" > Front-end news </a></li>
</ul>
JavaScript section (specifies the navigation for the current page plus. On's Class)
$ (function () {
var a1 = document. URL;
var a2 = $ ("#nav a");
for (var i = 0; i < a2.length i++) {
if (A1.indexof ($ (a2[i)). attr ("href"))!=-1) {
$ (a2[i]). Parent () ADDCLA SS ("on");
return;
}
$ (a2[0]). Parent (). addclass ("on");
CSS section (can be adjusted according to their own needs)
#nav li{
Display:inline-block;
Float:left;
Text-align:center;
height:36px;
padding-left:4px;
line-height:36px;
Background:url (images/nav.gif) no-repeat right bottom;
}
#nav Li a{
display:block;
Color: #777;
padding:0 15px 0 10px;
}
#nav li.on{
font-weight:bold;
Background:url (images/nav.gif) no-repeat 0 0;
margin-left:-3px;
}
#nav li.on a{
background:url (images/nav.gif) no-repeat right 0;
}
I hope this article will help you with your JavaScript programming.