Reputation: 11
Simple question: I need this function to loop infinitely. I've tried setTimeout
(I added up the time for all the steps to execute).
<script type="text/javascript">
$(document).ready(function slideshow(){
$('#slide1').show(500).delay(500)
.animate({width:'240px'}).delay(500)
.animate({height:'50px', width:'410px'}).delay(1500)
.hide(500)
});
</script>
Upvotes: 1
Views: 67
Reputation: 3016
setInterval(function() {
$('#myelem').stop().animate({ changes }, 500);
}, 1000);
Every second your element with animate with whatever properties you want it to. You can use setTimeout
, although setInterval
is designed for looping. Either works.
The key difference with my answer is the use of stop()
. It stops the previous animation, preventing any weird double-up bugs.
Upvotes: 0
Reputation: 388316
Try
jQuery(function($){
function anim(){
$('#slide1').show(500).delay(500)
.animate({width:'240px'}).delay(500)
.animate({height:'50px', width:'410px'}).delay(1500)
.hide(500, function(){
setTimeout(anim, 500)
})
}
anim();
})
Upvotes: 4