πŸ‹ Smooth scrolling

hayoungΒ·2023λ…„ 3μ›” 22일
0

JavaScript-DOM

λͺ©λ‘ 보기
3/5
post-thumbnail
  • btnScrollTo: λˆ„λ₯΄λ©΄ 슀크둀 λ˜λŠ” λ²„νŠΌ
  • section1: λˆ„λ₯΄λ©΄ 이동될 μ˜μ—­
  • scrollIntoView: ν•΄λ‹Ή μ˜μ—­μœΌλ‘œ μ΄λ™ν•˜λŠ” λ©”μ„œλ“œ
const btnScrollTo = document.querySelector(".btn--scroll-to");
const section1 = document.querySelector("#section--1");

btnScrollTo.addEventListener('click', function(e){
  section1.scrollIntoView({ behavior: 'smooth' });
});
profile
Persistence pays off.

0개의 λŒ“κΈ€