// 要求: 随机生成颜色RGB  核心点 :(0,0,0)   rgb  每一组的数字取值范围是  0~255
// 需要随机生成 0~255 之间的整数
function getRandom(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// 返回我们要的颜色
function getRandomColor() {
var c1 = getRandom(0, 255);
var c2 = getRandom(0, 255);
var c3 = getRandom(0, 255);
return 'rgb(' + c1 + ',' + c2 + ',' + c3 + ')'
}
console.log(getRandomColor());
// 下面的代码我们不研究 只是 给你演示我们写的程序没有错误
window.onload = function() {
document.body.style.backgroundColor = getRandomColor();
}

js随机背景颜色的更多相关文章

  1. 关于更改MYECLIPSE JS 代码背景颜色

    白色的背景,看花了眼,你想改一下编辑器的背景颜色,移步这里就可以了. 这时你高兴的打开编辑器,发现颜色确实变了,但是当你打开有JS的JSP时,你碉堡了,发现JS的背景颜色还是默认的, 看着让人纠结,好 ...

  2. js获取背景颜色

    //js获取背景颜色var Airport=$("#Airport").css('background-color'); js设置背景颜色 $("#intercity&q ...

  3. ios开发之--随机背景颜色

    记录个随机背景颜色的方法: + (UIColor*) randomColor{ NSInteger r = arc4random() % ; NSInteger g = arc4random() % ...

  4. js切换背景颜色

    我将全部的代码上传到了github,你可以下载查看 <!-------change the background color--------------> <script> f ...

  5. 记录一个js切换随机背景颜色的代码

    <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...

  6. js随机模块颜色

    <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content ...

  7. JS随机产生颜色

    <script> function selectForm(lowerValue,upperValue){ var choices=upperValue-lowerValue+1; retu ...

  8. js随机生成颜色代码

    function generyRandomColor() { return '#' + ('00000' + (Math.random() * 0x1000000 << 0).toStri ...

  9. js随机生成颜色的方法

    function getRandomColor() { return '#' + (Math.random() * 0xffffff << 0).toString(16); }

随机推荐

  1. 2017年BackBox5和Ubuntu16.04.1国内更新源

    BackBox是基于Ubuntu的Linux发行版,因此,我们可以使用Ubuntu的更新源作为BackBox的更新源. 1.查看系统版本信息: 输入: uname -a 显示计算机及操作系统的有关信息 ...

  2. HttpMessageConverter 专题

    配置HttpMessageConverterHttpMessageConverter是对http的request和response进行自动转换配置HttpMessageConverter可重载下面两个 ...

  3. spring boot -Properties & configuration

    72. Properties & configuration72.1 Automatically expand properties at build timeRather than hard ...

  4. 详解MUI顶部选项卡(tab-top-webview-main)的用法

    最近用MUI做手机app的时候,遇到了一点问题.然后就对这个tab-top-webview-main的源码做了点研究,接下来我将和大家详解一下 tab-top-webview-main的用法和应该注意 ...

  5. QM

    答案: C 解题: 1. PV = 1,2 / 11% = 10.91 NPV = PV(inflow)-PV(outflow) = 10.91 - 8 = 2.91 2. IRR : NPV = 0 ...

  6. Java设计模式之《适配器模式》及应用场景

    转自https://www.cnblogs.com/V1haoge/p/6479118.html 适配器就是一种适配中间件,它存在于不匹配的二者之间,用于连接二者,将不匹配变得匹配,简单点理解就是平常 ...

  7. bolt_storage.go

    package, * time.Second})     if err != nil {         return nil, err     }     err = db.Update(func( ...

  8. nsq源码阅读笔记之nsqd(一)——nsqd的配置解析和初始化

    配置解析 nsqd的主函数位于apps/nsqd.go中的main函数 首先main函数调用nsqFlagset和Parse进行命令行参数集初始化, 然后判断version参数是否存在,若存在,则打印 ...

  9. auth.go

    ), fmt.Errorf("invalid permission type: %s", s) } type authenticator struct {     conn *gr ...

  10. POJ_3304_Segments_线段判断是否相交

    POJ_3304_Segments_线段判断是否相交 Description Given n segments in the two dimensional space, write a progra ...