...怎么样用JS把DIV里面的背景颜色不停的切换颜色? 可以加我QQ:3715593...
发布网友
发布时间:2024-10-02 11:58
我来回答
共1个回答
热心网友
时间:2024-10-03 10:41
<div id="wrap" style="width: 100px; height: 100px;"></div>
<script type="text/javascript">
var wrap = document.getElementById( "wrap" );
var colors = [ "red", "black", "white", "green", "blue", "yellow" ];
var t = 1000;
var count = 0;
setInterval(function()
{
wrap.style.backgroundColor = colors[ count ];
count++;
if( count >= colors.length )
{
count = 0;
};
}, t);
</script>