Answers for "stop default scroll to target hash"

1

body animate does not stop on hash id

jQuery(function($) {
  $('a[href*="#"]:not([href="#"])').click(function() {
      var target = $(this.hash);
        $('html,body').stop().animate({
          scrollTop: target.offset().top - 120
        }, 'linear');   
  });    
	if (location.hash){
    var id = $(location.hash);
	}
	$(window).load(function() {
  	if (location.hash){
    	$('html,body').animate({scrollTop: id.offset().top -120}, 'linear')
  	};
 	});
})(jQuery);
Posted by: Guest on July-16-2020

Browse Popular Code Answers by Language