jQuery Scroll to next div

I have a div with an anchor wich i would like to use to go to an other div on the page:

<div class="scroll-down"><a href="#" class="next">See portfolio</a></div>

I have the following jQuery function:

$(".next").click(function(event) {
    event.preventDefault();
    $('html, body').animate({
        scrollTop: $(this).closest('.portfolio').next().offset().top
    }, 800, 'easeOutExpo');
});

when the anchor is clicked the page should scroll to a div with the class portfolio, but nothing is happening. What am I doing wrong?

Thank you in advance

What is the value for:

  • $(this).closest(‘.portfolio’).next().offset().top ?
  • $(this).closest(‘.portfolio’).next().offset() ?
  • $(this).closest(‘.portfolio’).next() ?
  • $(this).closest(‘.portfolio’) ?
1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.