Skip to content

Instantly share code, notes, and snippets.

@thunsaker
Created March 6, 2011 07:28
Show Gist options
  • Save thunsaker/857108 to your computer and use it in GitHub Desktop.
Save thunsaker/857108 to your computer and use it in GitHub Desktop.
Randomly Select a predefined list of background colors.
$(document).ready(function () {
$('.links_wrapper a').hover(
function () {
var hue = Math.floor(Math.random() * 256);
switch (hue % 3) {
case 0:
// orange
$(this).css('background', '#FC9E00');
break;
case 1:
// green
$(this).css('background', '#4FBA00');
break;
case 2:
// gray
$(this).css('background', '#818181');
break;
default:
// orange
$(this).css('background', '#FC9E00');
break;
}
},
function () {
$(this).css('background', 'white');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment