TGViewer
Html and Css & Jsآموزش Html and Css & Jsآموزش @htmlcss_channels · 23.1K subscribers
Post #2234 2.08K
Making smooth scrolling to elements using the scrollIntoView method

JS:

const links = document.querySelectorAll('.link');

links.forEach((item) => {
item.addEventListener('click', (e) => {
e.preventDefault();

let id = item.getAttribute('href');
let formattierID = id.substring(1);
let section = document.getElementById(formattierID);

section.scrollIntoView({
behavior: 'smooth',
});
});
});



💎 @Htmlcss_channels | #css #JavaScript #HTML
  • ❤ 2
More from @htmlcss_channels
  1. Sep 28, 2026🤖 خداحافظی با جستجوی خسته‌کننده منابع! اگه کار شما با گرافیک، تدوین یا هوش مصنوعی گره خور…
  2. Sep 28, 2026📚 آرشیو معتبرترین مجلات جهان 🆔 @EnglishMagazines_PDF ▪️▪️▪️▪️▪️▪️▪️▪️▪️ ⛳️ @Armisstab .
  3. Sep 28, 2026🤖 نسل جدید فیلترشکن‌های EASY2RAY با استفاده از هوش مصنوعی! 📱 اتصال بدون دردسر و بدون نیا…
  4. Sep 28, 2026؛CSS Clamp — اندازه‌گذاری هوشمند فرمول ساده ؛clamp(کمترین, مقدار_ایده‌آل, بیشترین) مثل یه…
  5. Sep 28, 2026🔅 CSS Clamp clamp(minimum, preferred, maximum); In this example, the preferred value is 5…
  6. Sep 26, 2026برای معرفی پروژه هاتون به کارفرما بهتره از این روش استفاده کنید این وبسایت پروژه هاتون رو…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →