Home › Forums › CSS › Jquery Slide animation toggle back and forth › Re: Jquery Slide animation toggle back and forth
April 20, 2013 at 10:57 am
#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
});
}
});