Liam
Liam

Reputation: 9855

Make div animate up and down with jQuery

Im trying to get a div move up and down from its current position during a mouse hover event - I have the followng but it only works once and then stops as opposed to continually cycling?

tiptitle.stop(true, true).animate({
    'top': '5px'
}, 100).stop(true, true).animate({
    'top': '0px'
}, 100);

Upvotes: 0

Views: 157

Answers (1)

Pete
Pete

Reputation: 58432

make an infinite loop

function animate(isOpen) {
    tiptitle.stop().animate({'top': isOpen ? '5px' : '0px'}, 100, function() { animate(!isOpen); })
}

Upvotes: 2

Related Questions