Есть три кнопки в хэдере и каждая из них привязана к своему блоку на странице. Как мне поправить скрипт что бы при нажатии на кнопку был переход на нужный блок и он(блок) находился посредине окна?
$(document).ready(function() {
$("#header").on("click", "button", function(event) {
var id = $(this).attr('href'),
top = $(id).offset().top;
$('body,html').animate({
scrollTop: top
}, 1500);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<header id="header">
<button href=".header">Home</button>
<button href="#joinTo">How join to?</button>
<button href=".form">Contact Us</button>
</header>