jQuery .click .animate向下移动,然后向上移动

Cai*_*ene 4 jquery

到目前为止,我设法做到这一点,它以120的增量向下移动,但我希望它上下,而不是上下......我希望我已经解释了这一点,所以"有人"会理解.

  <script>
  $(document).ready(function() {
    $('#footertab').click(function() {
      $('#footer').animate({
        bottom: '-=120'
      }, 1000, function() {
        // Animation complete.
      });
    });
  });
  </script>
Run Code Online (Sandbox Code Playgroud)

Sim*_*mon 7

如果我做对了,你就想要切换页脚的位置.这可以使用.toggle() - 函数完成:

$(document).ready(function() {
  $('#footertab').toggle(function() {
    $('#footer').animate({
      bottom: '-=120'
    }, 1000);
  },function() {
    $('#footer').animate({
      bottom: '+=120'
    }, 1000);
  })
});
Run Code Online (Sandbox Code Playgroud)