[JavaScript] [jQuery]代码实现锚点scoll效果 →→→→→进入此内容的聊天室

来自 , 2019-06-16, 写在 JavaScript, 查看 104 次.
URL http://www.code666.cn/view/4582ef60
  1. $('a[href*=#]').click(function() {
  2.    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
  3.    && location.hostname == this.hostname) {
  4.      var $target = $(this.hash);
  5.      $target = $target.length && $target
  6.      || $('[name=' + this.hash.slice(1) +']');
  7.      if ($target.length) {
  8.        var targetOffset = $target.offset().top;
  9.         var obj = document.documentElement;
  10.      if (jQuery.browser.safari)
  11.            obj = document.body
  12.     if (jQuery.browser.msie)
  13.            obj = 'html';
  14.       $(obj).animate({scrollTop: targetOffset}, 1000);
  15.         return false;
  16.      }
  17.    }
  18.  });
  19.  
  20. //javascript/1041

回复 "[jQuery]代码实现锚点scoll效果"

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

captcha