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

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -