我是靠谱客的博主 舒服电脑,这篇文章主要介绍jQuery实现锚点scoll效果实例分析,现在分享给大家,希望可以做个参考。

本文实例讲述了jQuery实现锚点scoll效果的方法。分享给大家供大家参考。具体实现方法如下:

复制代码 代码如下:
$('a[href*=#]').click(function() {
   if (location.pathname.replace(/^//,'') == this.pathname.replace(/^//,'')
   && location.hostname == this.hostname) {
     var $target = $(this.hash);
     $target = $target.length && $target
     || $('[name=' + this.hash.slice(1) +']');
     if ($target.length) {
       var targetOffset = $target.offset().top;
       var obj = document.documentElement;
     if (jQuery.browser.safari)
           obj = document.body
    if (jQuery.browser.msie)
           obj = 'html';
      $(obj).animate({scrollTop: targetOffset}, 1000);
       return false;
     }
   }
});

希望本文所述对大家的jQuery程序设计有所帮助。

最后

以上就是舒服电脑最近收集整理的关于jQuery实现锚点scoll效果实例分析的全部内容,更多相关jQuery实现锚点scoll效果实例分析内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(223)

评论列表共有 0 条评论

立即
投稿
返回
顶部