Change text to pseudo-random color using jquery

Viewed 451

I'd like to change the text color using the following code, but I get an error: Uncaught syntax: unexpected string when .each is called. I'm not sure what's wrong.

function random_rgb() {
  colors = ['8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
  r = colors.eq(Math.floor(Math.random * 8));
  g = colors.eq(Math.floor(Math.random * 8));
  b = colors.eq(Math.floor(Math.random * 8));
  return '#' + r + g + b;
};

$(document).ready({

  $("span.number").each(function(){
    this.style.color = random_rgb();
  });

});

UPDATE

I've created a jsfiddle (forgive me I'm not great w/ this app) https://jsfiddle.net/yrnqr566/

The color turns up black every time.

3 Answers
Related