html - Javascript .className not working -


i'm trying use bit of js change class of links referring current url. seems work halfway, .classname bit won't work. if use a[i].innerhtml = 'activelink' example, change innerhtml. firebug reports no errors.

window.onload = activatecurrentlink;  function activatecurrentlink(){     var = document.getelementsbytagname("a");     for(var i=0;i<a.length;i++)         if(a[i].href == window.location.href.split("#")[0])             a[i].classname += 'activelink'; } 

i have admit copypasta, js knowledge very, limited. help?

you forget space symbol necessary when adding additional class element

a[i].classname += ' activelink'; 

Comments

Popular posts from this blog

javascript - ScrollTo Effect (href to div) -

javascript - ng-class not responding to change in model in Angular? -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -