JS生成随机颜色(rgb)
2021-03-23 05:26
标签:rgb ffffff ret math ring rand tostring string func JS生成随机颜色(rgb) 标签:rgb ffffff ret math ring rand tostring string func 原文地址:https://www.cnblogs.com/tongsi/p/12690407.html/*随机获取颜色*/
function getRandomColor() {
var r = Math.floor(Math.random() * 256);
var g = Math.floor(Math.random() * 256);
var b = Math.floor(Math.random() * 256);
return "rgb(" + r + ‘,‘ + g + ‘,‘ + b + ")";
//return ‘#‘ + Math.floor(Math.random() * 0xffffff).toString(16);
}