创建随机颜色的函数

1
2
3
4
5
6
7
8
function getRandomColor(){
var colorArr = ['1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'];
var color = "";
for(var i = 0; i < 6; i++){
color += colorArr[Math.floor(Math.random()*16)];
}
return "#"+color;
}