2009
10.07

Today I had to make a function for a client of mine so I decided to share it with you.

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

This function needs jQuery

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

Of course you can change slow to normal or fast or even a int in milliseconds.

And to call it

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

Enjoy

  • Share/Bookmark

Related Posts:

8 comments so far

Add Your Comment
  1. This code saved me, I’ll send you a link to the site I’m working on when its finished.

  2. Glad to hear this ! Good luck

  3. ABSOLUTELY BRILLIANT!! I have been looking for this for a long time!! Thank you soooo much!!

  4. always share the code you write for your clients! :D

  5. thanks! at least i can understand this tutorial

  6. thanks.
    I avoid installing “scrollTo” jQuery plugin (which is good but too much for what I needed =)

  7. im so new with this…. where should i put this code? within the head tag?

  8. Works perfect!!!!!!!!!!! Thanx so much!!!!!!!!!

Security Code: