Home › Forums › CSS › Previous CSS Snippet Jquery Smooth Scroll Help › Re: Previous CSS Snippet Jquery Smooth Scroll Help
May 17, 2012 at 10:38 pm
#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);
});
}
}
});