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
Post a Comment