Using .animate On Scrolltop
How do I go by adding .animate to this piece of code? $('body,html').scrollTop($('#wrapper3').position().top); I have tried adding .animate before scrollTop, but it keeps showing
Solution 1:
It's not very clear what and how you want to achieve your result, but if I understood what you meant you can do:
<h1id="anchor">Lorem Ipsum</h1><p><ahref="#anchor"class="topLink">Back to Top</a></p>
And jQuery:
$("a.topLink").click(function() {
$("html, body").animate({
scrollTop: $($(this).attr("href")).offset().top + "px"}, {duration: 500, easing: "swing"
});
returnfalse;
});
The #anchor can be changed to what you want and the "Back to Top" is going to go to your #anchor. Just make sure the div (or in this case h1) has an idenditcal id.
Here is a Fiddle
A POSSIBLE REASON for jumping to the top of the page is the fact you have NOT loaded jQuery. Make sure jQuery IS LOADED.
EDIT
Ok after your edits you should just change this
<div id="bar16"></div>
to this
<divid="bar16"><ahref="#wrapper3"class="topLink">CLICK HERE</a></div></div>
Like here: Fiddle
Post a Comment for "Using .animate On Scrolltop"