数组应用随机改变网页背景色

<script type="text/javascript">
//定义颜色数组
var colors=["red","blue","yellow","green","#ff00ff"];
//取整
document.bgColor=colors[Math.floor(Math.random()*colors.length)];
</script>

 

你可能感兴趣的:(数组应用随机改变网页背景色)