CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   "random" link colors? (http://www.codingforums.com/showthread.php?t=179341)

snl 10-11-2009 03:00 AM

"random" link colors?
 
I have a div with a bunch of links. I'd like to specify a list of colors and then have the link list be randomly assigned the colors from the list. Can anyone help me with this? I've found scripts which will color all the links in the same random color upon reload, but I'd like all the links to be different colors. I hope this makes sense. :o

Fumigator 10-14-2009 10:24 PM

Use the jquery selector to select all anchor tags, then change the CSS for each element, randomly assigning color.

Something like..

PHP Code:

$(function() {
    $(
"a").each(function (i) {
         $(
this).css("color",getRandomColor());
    });
});

function 
getRandomColor() {
//return a random color value




All times are GMT +1. The time now is 07:51 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.