<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

最新文章

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

热门文章

  1. PHPExcel导出工作蒲(多表合并)教程+详细代码解读
  2. nth_element函数
  3. win7+ubuntu双系统安装
  4. android应用的资源
  5. 记录一次工作中jvm被linux杀死的调查
  6. 杭电多校第一场-B-Operation
  7. SpringCloud服务消费有哪几种方式?
  8. js循环给li绑定事件实现和弹出对应的索引
  9. 线程池 一 ScheduledThreadPoolExecutor
  10. [Grt]一篇简单概括XML