154
rated 0 times
[
159]
[
5]
/ answers: 1 / hits: 139451
/ 11 Years ago, thu, july 18, 2013, 12:00:00
I want to have 4 buttons/links on the beginning of the page, and under them the content.
On the buttons I put this code:
<a href=#idElement1>Scroll to element 1</a>
<a href=#idElement2>Scroll to element 2</a>
<a href=#idElement3>Scroll to element 3</a>
<a href=#idElement4>Scroll to element 4</a>
And under links there will be content:
<h2 id=idElement1>Element1</h2>
content....
<h2 id=idElement2>Element2</h2>
content....
<h2 id=idElement3>Element3</h2>
content....
<h2 id=idElement4>Element4</h2>
content....
It is working now, but cannot make it look more smooth.
I used this code, but cannot get it to work.
$('html, body').animate({
scrollTop: $(#elementID).offset().top
}, 2000);
Any suggestions? Thank you.
Edit: and the fiddle: http://jsfiddle.net/WxJLx/2/
More From » jquery