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 - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -