jquery - Using Javascript to Scroll to an class once it has been shown by clicking a link -


i using slidetoggle function on page show or hide text when user clicks link.

the problem having content further down page not show when user clicks link because below fold, user has scroll down. is possible use javascript scroll down content appears when link has been clicked?

an example of code using below:

<p class="show-one"><a href="#">show one</a></p> <p class="content-one" style="display: none;"> hidden content goes here. </p> <script> $('.expand-one').click(function(){ $('.content-one').slidetoggle('slow'); }); </script> 

something should suit needs:

$('html, body').animate({scrolltop: $('.content-one').offset().top}, 1000); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -