滚动到jQuery

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了滚动到jQuery相关的知识,希望对你有一定的参考价值。

scrollTo jQuery
  1. $(document).ready(function(){
  2. $('a[href*=#]').click(function() {
  3. if (location.pathname.replace(/^//,'') == this.pathname.replace(/^//,'')
  4. && location.hostname == this.hostname) {
  5. var $target = $(this.hash);
  6. $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
  7. if ($target.length) {
  8. var targetOffset = $target.offset().top;
  9. $('html,body').animate({
  10. scrollTop: targetOffset
  11. }, 1000);
  12. return false;
  13. }
  14. }
  15. });
  16. });

以上是关于滚动到jQuery的主要内容,如果未能解决你的问题,请参考以下文章