Question

In jQuery: I'd like to create an link to on click shows a hidden div (got that working by now) but also slides to it with a smooth-scroll effect. How do I combine the two?

Thanks so much.

Was it helpful?

Solution

You can use the scrollTo plugin to give smooth scoll effects.

Demo here.

OTHER TIPS

It’s a oneliner but can add a really nice effect.

function goToByScroll(id){
    $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}

<script>
   goToByScroll("theIdIWantToGoTo");
</script>

http://djpate.com/2009/10/07/animated-scroll-to-anchorid-function-with-jquery/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top