javascript - jQuery - Scrolling to a location calculated by a var -


this question has answer here:

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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -