Hi.
Anybody know any methods to adding a class to the nav bar for each specific page (once selected)? Like above on the MyBB site nav bar.
Example:
Contact page =
<li class="current"><a href="contact.html" title="">Contact us</a></li>
(if you understand..)
You can use a javascript on-click function to set the target class active. Its that simple.
Somebody shared the code here before, forgot who ...
Quote:function setActive() {
aObj = document.getElementById('nav').getElementsByTagName('a');
for(i=0;i<aObj.length;i++) {
if(document.location.href.indexOf(aObj[i].href)>=0) {
aObj[i].className='active';
}
}
}
(2012-09-22, 01:25 PM)effone Wrote: [ -> ]You can use a javascript on-click function to set the target class active. Its that simple.
Somebody shared the code here before, forgot who ...
Quote:function setActive() {
aObj = document.getElementById('nav').getElementsByTagName('a');
for(i=0;i<aObj.length;i++) {
if(document.location.href.indexOf(aObj[i].href)>=0) {
aObj[i].className='active';
}
}
}
What would be the way to implement that? is it onClick="javascript:setActive" ??
It's not really what I'm after because it wont save when i load a open a new page.