JQuery Onclick Anchor Tag Scroll ke Div dengan posisi yang tepat

function offsetAnchor() {
  if (location.hash.length !== 0) {
    window.scrollTo(window.scrollX, window.scrollY - 30);
  }
}
// call this function after event fire offsetAnchor() //
$(document).ready(function(){
    $("a").on('click', function(event) {
       window.location.hash = '';
        if (this.hash !== "") {
            event.preventDefault();
            var hash = this.hash;
            $('html, body').animate({
                scrollTop: $(hash).offset().top
            }, 800, function(){
                window.location.hash = hash;
                offsetAnchor();
            });
        }
    });
});
7uc1f3r