我想將焦點設置爲id的文本框讓我們說,使用div.focus和animate()滾動到頁面頂部後,txtName。如何在設置動畫後設置焦點
是否有一個功能,指定在像document.ready之後執行動畫之後會在document.ready之後執行?
我用來滾動的代碼如下。
$(".gototop").click(function(){
var focusElement = $("#contents");
$(focusElement).focus();
ScrollToTop(focusElement);
});
function ScrollToTop(el) {
$('html, body').animate({ scrollTop: $(el).offset().top - 50 }, 'slow');
}
你打我吧。 @Archie Dave,請參閱jQuery文檔以獲取動畫,其中「complete」參數是動畫完成時要調用的函數。 http://api.jquery.com/animate/ – devlord