Yesterday, in Javascript, colors were randomly selected from 10 colors and different colors were extracted each time. The specific implementation ideas are as follows, if you are interested, you can refer to the following example to randomly retrieve colors from 10 colors in Javascript yesterday. When the colors are different, you may consider a lot and use them as follows:
The Code is as follows:
Var colorList = ["# FFFF99", "# B5FF91", "#94 DBFF", "# FFBAFF", "# FFBD9D", "# C7A3ED", "# CC9898 ", "#8AC007", "# CCC007", "# FFAD5C"];
For (var I = 0; I Var bgColor = getColorByRandom (colorList );
}
Function getColorByRandom (colorList ){
Var colorIndex = Math. floor (Math. random () * colorList. length );
Var color = colorList [colorIndex];
ColorList. splice (colorIndex, 1 );
Return color;
}
In this way, the colors retrieved each time are random and different.