I am trying to create a function that will change the color of a span from black to a random color from a list of colors I have defined. My problem seems to be in the .css("color", variableName) part. I think I may be doing my syntax wrong. ( http://jsfiddle.net/crismanNoble/8gM76/ )
$(".randomRoll")
.mouseover(function() {
var colors = ["6F216C", "F34B0D", "C50102", "5DA537", "F1D81B"];
var pick = Math.floor(Math.random()*5);
var colorN = colors[pick];
$(this).css("color", colorN);
//alert(colorN);
})
.mouseout(function() {
$(this).css('color','black');
});
$(this).css("color","#" + colorN);would do the trick ...