Smooth scroll external link with id
I found this fiddle
http://jsfiddle.net/tovic/kw7LD/
that shows how to apply smooth scroll to external link with
class
. I'd like to know if is possible apply the same effect using
id
instead of
classes
.
- $(window).on("load", function () {
- var urlHash = window.location.href.split("#")[1];
- $('html,body').animate({
- scrollTop: $('.' + urlHash).offset().top
- }, 4000);
- });