DOM and assign the resultant array to the variable videos. I would like to use this array to loop over and extract some information.
I am noticing the code that follows this line, runs simultaneously and I get a null error while working with array's elements.
Question: Why does this happen? How do I wait on this statement to fully execute (and return a list of elements), before i run any other line of code that follows? (I do not want to manually put in a settimeout)
what
document.querySelector runs instantly
Nitpick: The DOM is already parsed. DOM is parsed HTML. What you probably meant to write was "search the DOM" or "traverse the DOM"
Sorry, clearly my brain wasn't fully functioning when i posted this. Here is some additional info. I found that the some of the elements i was looking for under parent nodes didn't exist. Therefore, the null error, when calling other methods like innerText on them. I added a bit of validation and error handling and that did it!
Thank you for correcting. I'll keep that in mind.
uhh yeah, also you might be running the querySelector at the wrong *time*
Обсуждают сегодня