Using jQuery to change hover colour (from array)? -
i wondering if possible use jquery change colour of link when hovered, getting colour randomly array? have following not sure how grab random colour.. might super easy can't seem work out..
var colors = array("#fb2900", "#ff7800", "#fff43b", "#8dfa30", "#01c86a", "#00d7b2", "#0092e3", "#002f7e", "#390e73"); $("ul.menu li a").hover(function(){ $(this).css("color","#f0f"); //random colour going here }, function() { $(this).css("color","#ffffff"); });
why not try like:
var colors = array("#fb2900", "#ff7800", "#fff43b", "#8dfa30", "#01c86a", "#00d7b2", "#0092e3", "#002f7e", "#390e73"), idx; $("ul.menu li a").hover(function(){ idx = math.floor(math.random() * colors.length); // pick random index $(this).css("color", colors[idx]); }, function() { $(this).css("color","#ffffff"); });
Comments
Post a Comment