Hi chaps, I am having a little problem. Given the following snippet:
html
<div id="carousel">
</div>
css
#carousel{
border:1px solid magenta;
width:600px;
height:258px;
background: url('sprite.png') no-repeat 0 0;
position:absolute;
left:0;
top:28%;
}
jquery
$(document).ready(function(){
function scroll(){
$("#carousel").animate({
backgroundPosition:'-600px'}, 500);
}
setInterval(function(){scroll()},2000);
});
I am trying to run scroll() forever to show different areas of the sprite in the css, but the function runs only once, how is that? I thought that calling setInterval
on scroll()
meant that it would run forever. Any idea?
thanks