Finding elements in Flask + Jinja

I am trying to create an flask app that uses Jinja templating. I have a navbar that contains links with the class name ‘nav-link’. They are in base.html. I dynamically create index.html. Later I try to acess the links in script.js:

const navLinks = document.querySelectorAll('.nav-link');

I log the navLinks into the console and this is what I get:

NodeList

Is there a way to get dynamically created elements? A way to add event listenrs onto them? Thank you in advance.