Scroll to Element

Smooth scroll to a specific element on the page using its CSS selector.

Code

Utilities
const scrollToElement = sel => {
  document.querySelector(sel)?.scrollIntoView({ behavior: 'smooth' });
};
return "Scroll function created";

Parameters

CSS selector.

Browser·fetch() may be limited by CORS

More JavaScript Snippets