使用jQuery实现Smooth Vertical滚动时遇到问题
我正在构建一个连续滚动的网页,其导航应该跳转到页面上的不同位置。 我试图遵循这个例子 ,并实现一个jQuery平滑滚动效果。 HTML工作正常 – 链接会在您单击时将您带到页面上的其他位置,但jQuery滚动效果不起作用。
这是html的重要部分:
到目前为止这是javascript :(它与上面链接的教程网页上的内容完全相同)
$(function() { $('ul.nav a').bind('click',function(event){ var $anchor = $(this); $('html, body').stop().animate({ scrollTop: $($anchor.attr('href')).offset().top }, 1500,'easeInOutExpo'); event.preventDefault(); }); });
任何人都有任何想法,为什么这对我不起作用? 谢谢!
我刚删除’easeInOutExpo’:
$(function() { $('ul.nav a').bind('click',function(event){ var $anchor = $(this); $('html, body').stop().animate({ scrollTop: $($anchor.attr('href')).offset().top }, 1500); event.preventDefault(); }); });