JS随机产生颜色

<script>

function selectForm(lowerValue,upperValue){

var choices=upperValue-lowerValue+1;

return Math.floor(Math.random()*choices+lowerValue)

}

var colors=["red","green","blue","yellow","black","purple","brown"];

var color=colors[selectForm(0,colors.length-1)];

alert(color);

</script>

PS:如果不懂,可查阅《JS高程》 P136

上一篇:Makefile 第九章 让make自动推导


下一篇:c语言实现顺序表的基本操作