亲们。 怎么样用JS把DIV里面的背景颜色不停的切换颜色? 可以加我QQ:371559318,或发邮箱。谢谢。。急急 5
展开全部
<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>
<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>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询