Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Previous CSS Snippet Jquery Smooth Scroll Help Re: Previous CSS Snippet Jquery Smooth Scroll Help

#103006
Taufik Nurrohman
Participant

Why you don’t like #hash? -..-

  $('a[href*=#]').each(function() {
var thisPath = filterPath(this.pathname) || locationPath;
if ( locationPath == thisPath
&& (location.hostname == this.hostname || !this.hostname)
&& this.hash.replace(/#/,'') ) {
var $target = $(this.hash), target = this.hash;
if (target) {
var targetOffset = $target.offset().top;
$(this).click(function(event) {
event.preventDefault();
// $(scrollElem).animate({scrollTop: targetOffset}, 400, function() {
// location.hash = target;
// });
$(scrollElem).animate({scrollTop: targetOffset}, 400);
});
}
}
});