Похожие чаты

Hi! I want let videos = document.querySelector() to parse the

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)

6 ответов

21 просмотр

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"

Justin-K Автор вопроса
Thomas
document.querySelector runs instantly

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!

Justin-K Автор вопроса
Simen
Nitpick: The DOM is already parsed. DOM is parsed ...

Thank you for correcting. I'll keep that in mind.

Justin K
Sorry, clearly my brain wasn't fully functioning w...

uhh yeah, also you might be running the querySelector at the wrong *time*

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта