实现步骤解析:


     * 这原本就是一个鼠标后面跟随一串小方块的效果,
     * 后来我就想,运用之前学的随机数的案例把小方块的颜色做成彩色的,
     * 并且每一个小方块的色彩是随机分配而不是我自己手动填写的。

1 function getColor(){
2                     var oMath = Math.floor(Math.random()*255);
3                     var rgb = "rgb("+
4                     Math.floor(Math.random()*255)+","+
5                     Math.floor(Math.random()*255)+","+
6                     Math.floor(Math.random()*255)+")";
7                     return rgb;
8                 }
随机颜色值封装函数

相关文章:

猜你喜欢
相关资源
相似解决方案