RGB生成随機顔色
function createColor() {
var r = Math.floor(Math.random() * 255);
var g = Math.floor(Math.random() * 255);
var b = Math.floor(Math.random() * 255);
return "rgb(" + r + "," + g + "," + b + ")";
}
生成十六進制的顔色值 #000000
function createColor2() {
return "#" + function (color) {
return new Array(7 - color.length).join("0") + color;//不夠六位則在前面補0
}((Math.random() * 0x1000000 << 0).toString(16));
}