[javaScript] 제이쿼리 없이 자바스크립트 top 버튼 만들기
scrollTop('js-button', 500); function scrollTop(elem,duration) { let target = document.getElementById(elem); target.addEventListener('click', function() { let currentY = window.pageYOffset; let step = duration/currentY > 1 ? 10 : 100; let timeStep = duration/currentY * step; let intervalID = setInterval(scrollUp, timeStep); function scrollUp(){ currentY = window.pageYOffset; if(currentY === 0) {..
WebPublisher
2021. 2. 20. 18:11
공지사항