0

I have the following script:

$('.how-we-do-it .items div').on('click', function () {
    var $matchingDIV = $('.how-we-do-it .sections .section .content div.' + $(this).attr('class'));
    $matchingDIV.toggle('fast');
});

I have been trying to add in some additional code so that the page automatically scrolls down to the $matchingDIV that gets toggled.

I have been trying to use scrollTop and also the Smooth Scroll plugin to accomplish this, but I cannot get it to work with my $matchingDIV output.

What would be the easiest way to accomplish this?

Zach Nicodemous
  • 9,097
  • 9
  • 45
  • 68

1 Answers1

2

try animating the scrollTop property of the html and body:

$("html, body").animate({ scrollTop: $matchingDIV.offset().top }, delay);
gion_13
  • 41,171
  • 10
  • 96
  • 108