如何在每次设置最后显示的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@