首页 > 代码库 > 获取随机颜色js

获取随机颜色js

获取随机颜色
方法一:

function randomColor1() {     var rand = Math.floor(Math.random() * 0xFFFFFF).toString(16);     if(rand.length == 6){         return rand;     }else{         return randomColor();     }}

 

方法二:

function randomColor2(){    return ‘#‘+(‘00000‘+(Math.random()*0x1000000<<0).toString(16)).slice(-6);}

 

获取随机颜色js