<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
function init()
{
var divs = document.getElementsByTagName("div");
for(i=0;i<divs.length; i++){
divs[i].style.backgroundColor = getRandomColor();
}
}
function getRandomColor(){
return '#' +
(function(color){
return (color += '0123456789abcdef'[Math.floor(Math.random()*16)])
&& (color.length == 6) ? color : arguments.callee(color);
})('');
}
</script>
</head>
<body οnlοad="init()">
<div style="width:500px; border-style:solid; overflow:hidden;" id="dzj">
<div style="width:40%; height:150px; float:left;">
<div style="width:33%;"></div>
<div style="width:33%;"></div>
<div style="width:33%;"></div>
</div>
<div style="width:40%; height:150px; float:right;">
</div>
</div>
</body>
</html>
随机填充div背景色
最新推荐文章于 2021-06-17 04:35:05 发布