【javascript】随机颜色
调用该方法则会返回一个#xxx的rgb随机颜色
1 function color1(){ 2 var sum=""; 3 var shuzu2=['a','b','c','d','e','f','0','1','2','3','4','5','6','7','8','9']; 4 for(var i=1;i<=3;i++){ 5 var int2=parseInt(Math.random()*shuzu2.length); //生成随机下标 6 sum+=shuzu2[int2]; //将该下标所对应的值保存 7 } 8 var sum2="#"+sum; //将值字符串连然后保存 9 sum=""; 10 return sum2; 11 }