<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body id="body">
<input type='button' value='刷新页面,随机改变颜色'/>
</body>
</html>
<script>
var r = Math.floor(Math.random() *256);
var g = Math.floor(Math.random() *256);
var b = Math.floor(Math.random() *256);
console.log(b);
var color = "rgb("+r+","+g+","+b+")";
console.log(color)
var bd = document.getElementById("body")
bd.style.background= color;
</script>
点击刷新按钮,切换颜色