rentageekmom of LDM Devs
12/15/2015 - 2:00 PM

Smooth scroll to a DIV with an ID vs. using name anchors

Smooth scroll to a DIV with an ID vs. using name anchors

jQuery(function($) {
  $('a[href*="#"]:not([href="#"],[data-toggle])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('#' + target');
      if (target.length) {
        $('html,body').animate({
          scrollTop: $(target).offset().top - 200 // offset for how tall your menu is
        }, 1000); // duration time of scroll
        return false;
      }
    }
  });
});