[英]jQuery animate speed not working? Animation instant - not smooth
遇到jQuery .animate
功能的一些問題。
我在我的網站上實現了“返回頂部”鏈接: http : //www.unforgivengamers.com/
一旦你點擊它,它應該會讓你回到頁面的頂部。
這是我的jQuery代碼:
<script type="text/javascript">
jQuery.noConflict();
jQuery('a[href=#top]').click(function(){
jQuery('html, body').animate({scrollTop:0}, 'slow');
return false;
});
</script>
問題:動畫不流暢! 我想讓它慢慢滾動,而不是瞬間滾動。
像這樣: http : //designwoop.com/labs/smooth%20scroll/smooth-scroll.html
我在這里錯過了一些東西嗎?
我正在使用jQuery 1.8.3
您應該將代碼放在文檔就緒處理程序中,甚至不在頁面上執行動畫,錨點位於頁面底部,而代碼在頁面頂部沒有文檔准備就緒。
jQuery(document).ready(function(){
jQuery('a[href=#top]').click(function(){
jQuery('html, body').animate({scrollTop:0}, 'slow');
return false;
});
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.