javascript - jQuery Random Item from Array Not Working -
i trying assign random background color reach td. have array:
var randomcolor = ["red","blue","green","mint","yellow","lightpurple"];
and function:
function setrandomcolor(){ return randomcolor[math.floor(math.random() * randomcolor.length)]; }
here jsfiddle:
you'll notice every 2-3 times run program, td
cell random white. know why is? not have white in array option. not sure why td
cell's generating white background.
any appreciated!
thanks
lightpurple
, mint
not valid color keywords. error such
expected color found 'mint'. error in parsing value 'background-color'. declaration dropped.
note "declaration dropped." @ end. means browser doesn't understand rule , hence doesn't assign background color element.
the valid keywords listed in specification:
the list of color keywords is: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, orange, purple, red, silver, teal, white, , yellow.
Comments
Post a Comment