abstract:<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title> divbackground </title> <style> div{width:100px;
<!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>
Correcting teacher:天蓬老师Correction time:2019-03-28 10:22:27
Teacher's summary:只要能打乱RGB中的数值, 就可以实现随机变化 , 要注意变化 的范围就可以了