How can I make the top position of an absolutely positioned div with children change every x seconds using jQuery? I tried using setInterval but it only changes once. Here is my code:
.com_prices {
width: 100%;
height: 100%;
overflow: hidden;
background: #dd0d0d;
position: relative;
}
.com_tabs {
position: absolute;
height: auto;
width: 100%;
}
.com_price_tab {
width: 90%;
margin: 10px auto;
height: 100px;
background: #fff;
}
The HTML
<div class="com_prices">
<div class="com_tabs">
<div class="com_price_tab"></div>
<div style="background: #28bc88" class="com_price_tab"></div>
<div style="background: #fff000" class="com_price_tab"></div>
<div style="background: #333" class="com_price_tab"></div>
<div style="background: #28bc88" class="com_price_tab"></div>
<div style="background: #999" class="com_price_tab"></div>
<div class="com_price_tab"></div>
<div class="com_price_tab"></div>
</div>
</div>
The script
setInterval(function() {
$('.com_tabs').animate({top: "-100px"}, 350);
}, 2000);