随机颜色生成
随机生成颜色
/* *随机颜色(十六进制代码) */ function randomHexColor() { var seed = Math.random(), result = seed.toString(16).substr(2, 6); while (result.length < 6) { result += '0' } return '#' + result; } /* *随机颜色(RGB值) */ function randomRgbColor() { var rgb = [ Math.floor(Math.random() * 255 + 1) , Math.floor(Math.random() * 255 + 1) , Math.floor(Math.random() * 255 + 1) ]; return 'rgb(' + rgb.join(',') + ')'; }