Answers for "prevent scroll on :target redirect"

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

Code answers related to "prevent scroll on :target redirect"

Browse Popular Code Answers by Language