Advertisement
koki2000

Jquery ScrollTo

Mar 29th, 2021
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery.noConflict();
  2. jQuery(document).ready(function ($) {
  3.    
  4.     var notif = location.search.replace("?","").split('=')[1];
  5.    
  6.    
  7.     if( notif != false)
  8.     {
  9.         $('#'+notif).css({"color": "#d9534f"});
  10.         var scrollTo = Math.floor( $('#'+notif).position().top );
  11.         window.scrollTo(0, scrollTo);
  12.     }
  13.    
  14.    
  15.     $('a[href^="#"]').on('click', function (event) {
  16.  
  17.         var target = $(this.getAttribute('href'));
  18.  
  19.         if (target.length) {
  20.             event.preventDefault();
  21.             $('html, body').stop().animate({
  22.                 scrollTop: target.offset().top
  23.             }, 1000);
  24.         }
  25.  
  26.     });
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement