Javascript实例:JS函数实现随机颜色

作者: 来源: 更新时间:2012-05-16 19:33:14 点击:
网页制作文章简介:随机颜色。

function randomcolor()
{
var colorvalue=["0","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],
colorprefix="#",
index;
for(var i=0;i < 6; i++){
index=Math.round(Math.random()*14);
colorprefix+=colorvalue[index];
}
return colorprefix;
}
var test=randomcolor();
alert(test);