Math.floor取整color = color.length == 1?‘0‘+color:color;rgb.pu
function getRandomColor(){ let rgb = []; for(let i=0;i<3;++i){ let color = Math.floor(Math.random()*256).toString(16); //Math.random()*256是生成0-256之间的随机小数,,Math.floor取整 color = color.length == 1?‘0‘+color:color; rgb.push(color); } return ‘#‘ + rgb.join(‘‘); }
一个生成随机颜色的js函数
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/30557.html
- 上一篇:asp获取隐藏域的json 并解析
- 下一篇:ssh文件上传、下载、预览