<html>
<head>
<title>DHTML动画</title>
<script type="text/javascript">
function init() {
var mdiv = document.getElementById("divmove");
mdiv.style.width = "250px";
mdiv.style.height = "130px";
mdiv.style.border = "black outset 3px";
mdiv.style.backgroundColor ="lightGray";
var colors = ["white", "yellow", "orange", "red"];
var nextColor = -1, len = colors.length, num, color;
var iTime = setInterval(function() {
num = ++nextColor;
color = colors[num%len];
mdiv.style.backgroundColor = color;
mdiv.innerHTML = "<h1 align='center'>"+ color +"</h1><h6>"+ num +"</h6>";
if(num==11) {
clearInterval(iTime);
}
}, 1000);
}
</script>
</head>
<body οnlοad="init()">
<div id="divmove"></div>
</body>
</html>
<head>
<title>DHTML动画</title>
<script type="text/javascript">
function init() {
var mdiv = document.getElementById("divmove");
mdiv.style.width = "250px";
mdiv.style.height = "130px";
mdiv.style.border = "black outset 3px";
mdiv.style.backgroundColor ="lightGray";
var colors = ["white", "yellow", "orange", "red"];
var nextColor = -1, len = colors.length, num, color;
var iTime = setInterval(function() {
num = ++nextColor;
color = colors[num%len];
mdiv.style.backgroundColor = color;
mdiv.innerHTML = "<h1 align='center'>"+ color +"</h1><h6>"+ num +"</h6>";
if(num==11) {
clearInterval(iTime);
}
}, 1000);
}
</script>
</head>
<body οnlοad="init()">
<div id="divmove"></div>
</body>
</html>