This was a question previously here Bootstrap scrollspy when accessing from another page
But that's jquery and I converted it to Javascript but is not working for me. Can you guys help me, please?
fixScrollSpy() {
var stripped_url = window.location.toString().split("#");
if (stripped_url.length > 1) {
var activeId = "#nav-deep-" + stripped_url[1];
activeId.addEventListener("click", () => {});
}
}
And also like this but none of them worked
fixScrollSpy() {
var stripped_url = window.location.toString().split("#");
if (stripped_url.length > 1) {
var activeId = "#nav-deep-" + stripped_url[1];
document.querySelector(activeId)[0].click();
}
}