Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Jquery Slide animation toggle back and forth Re: Jquery Slide animation toggle back and forth

#132512
CrocoDillon
Participant

Not sure why you won’t go with Gray’s `toggleClass()` solution, but here is one (buggy) implementation of an `if` statement. Buggy if you click during animation.

var container = $(‘#container’);
$(‘#arrow’).on(‘click’, function() {
if (parseInt(container.css(‘top’)) > 0) {
container.animate({
top: 0
});
} else {
container.animate({
top: 210
});
}
});