0

I have a page with several divs.

When the user clicks a button for a certain div which is half way down the page to be positioned centre so the top of the div is more like at the top of the page.

how do i do this using jquery?

Beginner
  • 28,539
  • 63
  • 155
  • 235
  • 1
    I really dont understand your question .... what should happen when the button is click ? scroll ? animation ? a `DIV` appears ? – Manse Apr 17 '12 at 09:19
  • sorry yeh just want the page to scroll down so the div at the bottom is in the center of the page – Beginner Apr 17 '12 at 09:20

1 Answers1

1

Try this

$("#button").click(function() {
     $('html, body').animate({
         scrollTop: $("#elementtoScrollToID").offset().top
     }, 2000);
 });

Also see jQuery scroll to element

Community
  • 1
  • 1
PiTheNumber
  • 22,828
  • 17
  • 107
  • 180