Search code examples
jqueryonclickhrefslideup

slideDown a div with anchor click then go to link


I want to have a jquery div slide down on a click of a anchor tag, which is working but I want it to animate first and then visit the clicked link. Is this possible?

   $('#portfolio').click(function() {
        $('#bodyG').slideUp('fast');
        });

Solution

  • $('#portfolio').click(function(e){
      e.preventDefault();
      var href = $(this).attr('href');
      $('#bodyG').slideUp('fast', function() {
        window.location = href;
      });
    });