限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(2025-02-06至2025-03-06)凡是购买苦力吧VIP/充值K币的新老用户,都直接可获得买一送一的优惠馈赠。例如:购买一个月的VIP会员可直接获得两个月的VIP会员;充值100K币可直接获得200K币,以此类推!有任何疑问可联系在线客服,感谢各位用户对苦力吧素材的信任与厚爱,我们将一如既往的给大家上新更多优质的素材源码,祝大家开工大吉、工作顺利、心想事成。

javascript在线随机生成可预览的随机背景颜色

所属分类: 网页特效-实用工具    2024-01-04 10:36:34

javascript在线随机生成可预览的随机背景颜色 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

javascript在线随机生成可预览的随机背景颜色(共3个文件)

    • index.html

使用方法

// Some Variables 
var genButton = document.getElementById("gen"), // Generate button
    clear  = document.getElementById("clear"),  // Clear button
    output = document.getElementById("randomNum"),  // Output space
    copy = document.getElementById("copy"),  // Copy to Clipboard Button
    copyCheck = document.getElementById("copyCheck");  // copy check
  

// Get Random Number Function && make it the background of the body xD
function getRandomNum() {
    "use strict";
    output.value = "#" + Math.floor((1e+5) + Math.random() * (9e+5)); // get random 6-digits number
  var bgClr = output.value; 
  document.getElementById("preview").style.backgroundColor = bgClr;  // set body bgColor to that random number
}
// Clear Random Number Function + make background of the body as default 
function clearNum() {
    "use strict";
    output.value = "";   // clear output space
   document.getElementById("preview").style.backgroundColor = "#F1A9A0";   // make bgColor of the body as default
}
// Copy the color code to the clipboard by clicking on "Copy" Button
function copyToClipBoard() {
  "use strict";
  document.execCommand("copy", false, output.select());
  copyCheck.style.right = "20px";
  showCheck = setTimeout(function() {
    copyCheck.style.right = "-200px";
  }, 3000);
  clearTimeout(showCheck);
}
// Adding EventListener to the buttons
genButton.addEventListener("click", getRandomNum);  // Generate Button
clear.addEventListener("click", clearNum);   // Clear Button
copy.addEventListener("click", copyToClipBoard);

//---------------- Thanks for being here --------------------- //

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 实用工具

jquery基于highlight.js在线代码编辑器工具

一款轻量级代码编辑器实用工具,主要功能:代码高亮显示、可调整大小的文本区域和代码行缩进。
  实用工具
 5216  0

javascript实现的交互式俄罗斯十珠大算盘计算器

一款老式的算盘算术计算器,算盘是一种用于算术计算的简单机械设备,可直观的演示并计算。有点类似于我国的算盘计算,我国算盘珠算的计算方法是基于“二进制”的基础来进行计算的。
  实用工具
 7341  0

jquery轻量级可拖拽移动关闭的对话框窗口

jDoor是一个轻量级精仿windows窗口插件,支持鼠标拖放移动关闭,还可以自定义加载外部网站视频位于窗口内,超实用。
  实用工具
 4319  0

jquery移动端贴纸拖拽移动拉伸

一款手机移动端图片拖拽工具,支持移动端放大收缩图片、拖拽图片。
  实用工具
 8274  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论