Your code can be simplified:
$(document).ready(function() {
(function foo () {
$('.balloon').stop(true).animate({top: "+=30"}, 1000, function () {
$(this).stop(true).animate({top: "-=30"}, 1000, foo);
});
})();
});
You can use +=30
to add 30px
to the top position. Same for -30px
.