标签:color div and 随机 颜色 space class 向上取整 return
var arr = [‘0‘, ‘1‘, ‘2‘, ‘3‘, ‘4‘, ‘5‘, ‘6‘, ‘7‘, ‘8‘, ‘9‘, ‘A‘, ‘B‘, ‘C‘, ‘D‘, ‘E‘, ‘F‘];
var sum = "";
for (var i = 0; i < 6; i++) {
//向上取整,得到进制数
var num= Math.ceil(Math.random() * 16);
sum += arr[id];
var sym = "#";
}
//生成进制数
var colourCode = sym + sum ;
//返回16进制颜色代码
return colourCode;
标签:color div and 随机 颜色 space class 向上取整 return
原文地址:http://www.cnblogs.com/AgilityJin/p/7323391.html