JS随机产生颜色
2024-09-05 17:37:04
<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
最新文章
- In-Memory:在内存中创建临时表和表变量
- 讯时网关IP对接PBX
- AX7: Get started developing
- 【POJ 2774】Long Long Message 最长公共子串
- Java Job
- FileOutputSream
- 项目中使用的ajax异步读取数据结构设计
- java正则表达式应用--验证字符串是否为数字(转载)
- heap(堆)和stack(栈)的区别
- 关于textbox.attributes[";value";]的问题
- runtime官方文档
- facenet 进行人脸识别测试
- 记录一个bootstrap惨痛的错误
- Unitek的USB3.0 TF卡读卡器
- JQ attr prop 区别
- CPU密集型和I/O密集型区别
- GSSAPIAuthentication=no
- ES5新增数组方法
- English-旅游英语及情景对话
- 【CentOS】设置服务开机自动启动