摘要:
divbackgroundvar 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);
//用到了随机数字
批改老师:天蓬老师批改时间:2019-03-28 10:22:27
老师总结:只要能打乱RGB中的数值, 就可以实现随机变化 , 要注意变化 的范围就可以了