返回做了一个 随机......登陆

做了一个 随机变化颜色

土豆烧牛肉2019-03-27 17:32:26170

<!DOCTYPE html>

<html>

 <head>

  <meta charset="UTF-8">

  <title> divbackground </title>  

  <style>

  div{width:100px;height:200px;margin:0px auto;border:1px solid red;}


  </style>

 </head>



 <body>

  <div id="d1"></div>

 </body>

<script>

var d1= document.getElementById("d1");

function foo(){

var arr=[0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f"]

var color = "#"+arr[Math.floor(Math.random()*arr.length)]+arr[Math.floor(Math.random()*arr.length)]+arr[Math.floor(Math.random()*arr.length)]+arr[Math.floor(Math.random()*arr.length)]+arr[Math.floor(Math.random()*arr.length)]+arr[Math.floor(Math.random()*arr.length)];


d1.style.background = color;



}


var t = setInterval(foo,500);

</script>

//用到了随机数字

</html>


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送