Skip to content

Instantly share code, notes, and snippets.

@cnix
Created August 9, 2008 23:41
Show Gist options
  • Save cnix/4709 to your computer and use it in GitHub Desktop.
Save cnix/4709 to your computer and use it in GitHub Desktop.
function sticky_clicky(list) {
var lis = list.getElementsByTagName('li');
var i = 0;
do
{
lis[i].style.cursor='pointer';
lis[i].addEventListener('click', color_me, false);
i++;
var last = false;
var color_me = function() {
if ( !last ) {
this.style.backgroundColor="#ff0000";
} else {
last.style.backgroundColor="";
this.style.backgroundColor="#ff0000";
}
last = this;
}
}
while ( i < lis.length )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment