随机16进制颜色练习

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>随机颜色</title>
</head>
<body>
<script>
    function getColr(){
        var colorValue = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f";
        var colorArray = colorValue.split(",");
        var color = "#";
        for(var i = 0; i < 6; i++){
            color += colorArray[Math.floor(Math.random()*16)]
        }
        return color;
    }
    console.log(getColr());
</script>
</body>
</html>

 

posted @ 2017-07-03 16:52  -CLAY-  阅读(211)  评论(0编辑  收藏  举报