When the user clicks a button, I want his browser to automatically scroll to an <a>
with a certain href (let's call it "abc"). Ideally the scrolling would be nicely animated in some way.
views:
126answers:
3
+4
A:
Give a look to the jQuery.scrollTo plugin.
With that plugin you could simply:
$.scrollTo('a[href=abc]');
CMS
2009-09-09 04:59:19
+2
A:
You don't need any plugin.
$(document.documentElement).animate({
scrollTop: $('a#abc').offset().top
});
J-P
2009-09-09 06:59:25
A:
Way simpler:
element_to_scroll_to = document.getElementById('anchorName2');
element_to_scroll_to.scrollIntoView();
Even no need for jQuery ;)
Mandx
2010-07-03 01:29:24