I know there are a lot of smooth scroll scripts on stack, and I have adopt them a lot in the past. As I do not want to use <a href="#">
links, I am using <buttons data-href="">
. This is my current code:
var $root = $('html, body');
$('.smooth').click(function() {
var href = $.attr(this, 'data-href');
$root.animate({
scrollTop: $(href).offset().top
}, 500, function () {
window.location.hash = href;
});
return false;
alert('smoothness');
});
And the necessary html part:
<button id="downarrow" data-href="#features" class="smooth">
<span>scroll down</span>
</button>
This works great, as seen right here: DEMO
I do not know why, but it does not work in my live site with the same code. You can check its build here: FULL DEMO