JS生成随机十六位的颜色的数值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
function getColor() {
var str="#";
var co=["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];
for (var j=0;j<6;j++)
{
colors=co[parseInt(Math.random()*15)];
str+=colors;
}
return str;
}
console.log(getColor());
</script>
</head>
<body>

</body>
</html>