js 随机颜色
<div id="time" style="width:60px;height:60px;"></div>
<script type="text/javascript">
// 思路:颜色由#、A-F、0-9组成
var str = "ABCDEF0123456789";
var color = "#";
for (var i = 0; i < 6; i++) {
var index = Math.floor(Math.random() * str.length);
color += str[index];
}
var oDiv = document.querySelector("#time");
oDiv.style.backgroundColor = color;
</script>


浙公网安备 33010602011771号