div.focus 및 animate()를 사용하여 페이지 상단으로 스크롤 한 후 txtName을 말하도록 id의 텍스트 상자에 포커스를 설정하려고합니다.애니메이션 후 초점 설정 방법
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