$(window).load(function() {
$('a.scroll').each(function() {
var id = $(this).attr('href');
if (id.match('^#')) {
var target = $(id).offset().top - 65;
var title = $(this).attr('title');
$(this).on('click tap', function() {
$('body').animate({
scrollTop: target
}, 1000);
history.pushState({
foo: title
}, title, id);
return false;
});
}
});
});
Same Page
<a href="pecas-servicos#qualidade" class="scroll" title="{!! trans('master.menu.qualidade')">Qualidade</a>
Another Page
<a href="pecas-servicos/contato#qualidade" class="scroll" title="{!! trans('master.menu.qualidade')">Qualidade</a>
When I'm on the HOME page and click on the LINK, the scrolling works until the section I clicked.
But if I'm on another page, it does not. It even goes to HOME, however, it goes down to the bottom of the page.