Похожие чаты

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 ответов

20 просмотров

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*

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

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

30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
Чёт не понял, я ж правильной функцией воспользовался чтобы вывести отладочную информацию? но что-то она не ловится
notme
18
Also, why can’t the community have a vote/ say when it comes to initiatives like buybacks. Isn’t the point of crypto decentralisation? Don’t we deserve input as long term supp...
👨🏽‍🦰
13
Привет)) уже кажется эту тему перемусолили, но вот я так и не понял. Я сейчас сижу на 27дюймов 2к мониторе. На Актуальной макоси, если я куплю 27д 4к монитор: - будет ли изобр...
Vladislav Piskunov
16
any reference of this implementation?
BitBuddha
29
Hi guys, any problem with Pulsebrige? Trying to transfer from wETH to ETH. First it tells me to connect my metamask "through mobile app" not desktop. Then I did and confirmed ...
Snowflakecrypto
13
Страшнейшая правда про списки ЦБ. С первых дней жизни P2P сферы, молодые человеки, начитавшись законодательной базы и "внутренних" документов, решили, что им противостоит сер...
Foxcool
3
У меня есть функция где происходит это: write_bit(buffer, 1); write_bit(buffer, 0); write_bit(buffer, 1); write_bit(buffer, 1); write_bit(buffer, 1); w...
~
13
Карта сайта