Can't select element (JavaScript)
I'm trying to make a project, it's porpuse is to basically update the navigation bar of a website I have to all pages at once every time I want to add a new link, so I don't have to go and add it in every page myself, and I have done this fine so far. I now however wanted to create another code, which code I want to interact with the navigation bar I created before, and it just doesn't work, it doesn't find the elements, I wanted to make it so that the link of the page you are currently viewing is replaced by a paragraph with an underline, it should be simple, but for some reason it doesn't work, I think it doesn't find the element because the code runs before the elements are created, but I'm not sure how to fix that, can anyone help? Here is the code: https://code.sololearn.com/WOQ27nkJ7alz/?ref=app