javascript – 在第一个位置显示最后一个fadeIn div

前端之家收集整理的这篇文章主要介绍了javascript – 在第一个位置显示最后一个fadeIn div前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我有10个div在随机时间显示.

如何在每次设置最后显示的div(排名第一的位置)而不是div的html顺序?

这是我的代码

@H_502_9@var myVar; function showDiv(){ var random = Math.floor(Math.random() * $('.notification').length); $('.notification').eq(random).fadeIn(200).delay(3000).fadeOut(200); createRandomInterval(); } function createRandomInterval(){ setTimeout(showDiv,500+ Math.random() * 4000); } $(document).ready(function(){ createRandomInterval(); }); @H_502_9@.notification { width: 200px; height: 50px; background-color: yellow; border: 1px solid rgba(0,0.2); margin-bottom: 5px; text-align: center; padding-top: 20px; display: none;/* hide initially so that fadIn() fadeOut() will work } @H_502_9@

猜你在找的CSS相关文章