Skip to content

Instantly share code, notes, and snippets.

@pinglamb
Created June 19, 2012 13:55
Show Gist options
  • Save pinglamb/2954365 to your computer and use it in GitHub Desktop.
Save pinglamb/2954365 to your computer and use it in GitHub Desktop.
Select Active Item JS
var links = document.getElementsByClassName('link');
var choose = function() {
for(var j=0; j < links.length; j++) {
links[j].className = '';
}
this.className = 'active';
};
for(var i=0; i < links.length; i++) {
links[i].addEventListener('click', choose, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment