Chartjs-My anchor tags are not working in my website after i added chart.js in it

0👍

Probably a little late, but either way, put this in a js file and load this js file after loading the chart.js file.

const links = document.querySelectorAll(".page-header ul a");

for (const link of links) {
  link.addEventListener("click", clickHandler);
}

function clickHandler(e) {
  e.preventDefault();
  const href = this.getAttribute("href");
  const offsetTop = document.querySelector(href).offsetTop;

  scroll({
  top: offsetTop,
  behavior: "smooth"
});

}

Leave a comment