Frontend

[jQuery] 최상단, 최하단 바로가기 애니메이트 버튼

불타는 코딩🔥 2019. 4. 11. 16:52

너무 간단하지만, 쓸 일이 많으므로 저장!


최상단으로 가는 버튼

 

html

<button type="button" id="goTop'"> go to ther TOP </button>

jQuery

$('#goTop').on('click', function(e){ 
     $("html, body").animate({ scrollTop : 0 }, "400") ;
     return false; 
});

최하단으로 가는 버튼

html

<button type="button" id="goBottom"> go to ther BOTTOM </button>

 

jQuery

$('#goBottom').on('click', function(e){ 
     $("html, body").animate({scrollTop : $(document).height() }, "400");
     return false; 
})