javascript - jQuery - Scrolling to a location calculated by a var -
this question has answer here:
- animate scroll id on page load 5 answers
i have 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 add in additional code page automatically scrolls down $matchingdiv gets toggled.
i have been trying use scrolltop , smooth scroll plugin accomplish this, cannot work $matchingdiv output.
what easiest way accomplish this?
try animating scrolltop
property of html
, body
:
$("html, body").animate({ scrolltop: $matchingdiv.offset().top }, delay);
Comments
Post a Comment