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 -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -