Jquery simple friendly scroll

this function is based on jquery 1.6.1 of mine,but i think its fit for most of the jqeury versions

function goToIdByScroll(id){
      $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
  }//scrol by the element ID
function goToAnchorByScroll(id) {
      $('html,body').animate({ scrollTop: $('a[href$="' + id+'"]').offset().top }, 'slow');
  }//scrol by the anchor that in the href

作者:KKcat
    
个人博客:http://jinzhao.me/
    
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/jinzhao/p/2092347.html