[JavaScript] 通过jQuery和内链平滑滚动 →→→→→进入此内容的聊天室

来自 , 2021-04-13, 写在 JavaScript, 查看 130 次.
URL http://www.code666.cn/view/b5944208
  1. $(function(){
  2.  
  3.     $('a[href*=#]').click(function() {
  4.  
  5.     if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
  6.         && location.hostname == this.hostname) {
  7.  
  8.             var $target = $(this.hash);
  9.  
  10.             $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
  11.  
  12.             if ($target.length) {
  13.  
  14.                 var targetOffset = $target.offset().top;
  15.  
  16.                 $('html,body').animate({scrollTop: targetOffset}, 1000);
  17.  
  18.                 return false;
  19.  
  20.             }
  21.  
  22.         }
  23.  
  24.     });
  25.  
  26. });
  27. //javascript/2500

回复 "通过jQuery和内链平滑滚动"

这儿你可以回复上面这条便签

captcha