document.querySelectorAll returns values only after inspecting DOMs
up vote
3
down vote
favorite
Trying to get these 2 elements having the same class with "document.querySelectorAll(".sc-gHboQg"), but it returns and empty NodeList:
As soon as I inspect the element:
only now I can get them:
As far as I understand these elements are outputted dynamically in javascript, probably react, but how can I get them without having to inspect them first?
javascript reactjs
|
show 1 more comment
up vote
3
down vote
favorite
Trying to get these 2 elements having the same class with "document.querySelectorAll(".sc-gHboQg"), but it returns and empty NodeList:
As soon as I inspect the element:
only now I can get them:
As far as I understand these elements are outputted dynamically in javascript, probably react, but how can I get them without having to inspect them first?
javascript reactjs
At what time are you getting the elements? are you waiting for DOMContentLoaded?
– Luis Cabrera Benito
Nov 21 at 18:44
Could there be another event at play, like mouseover, click, etc. triggering a class change?
– Logan Bertram
Nov 21 at 18:45
It's not time related, nor at play, mouseover or click on it, I tried them all without inspecting the element in the console, but nothing..
– Alessandro Crotti
Nov 21 at 18:50
I believe it's time-related. Try to get them after some time usingsetTimeout
– Dominik Krzywiecki
Nov 21 at 18:57
1
stackoverflow.com/questions/28163033/…
– chrisg86
Nov 21 at 19:08
|
show 1 more comment
up vote
3
down vote
favorite
up vote
3
down vote
favorite
Trying to get these 2 elements having the same class with "document.querySelectorAll(".sc-gHboQg"), but it returns and empty NodeList:
As soon as I inspect the element:
only now I can get them:
As far as I understand these elements are outputted dynamically in javascript, probably react, but how can I get them without having to inspect them first?
javascript reactjs
Trying to get these 2 elements having the same class with "document.querySelectorAll(".sc-gHboQg"), but it returns and empty NodeList:
As soon as I inspect the element:
only now I can get them:
As far as I understand these elements are outputted dynamically in javascript, probably react, but how can I get them without having to inspect them first?
javascript reactjs
javascript reactjs
edited Nov 21 at 18:44
chazsolo
4,9371232
4,9371232
asked Nov 21 at 18:43
Alessandro Crotti
727
727
At what time are you getting the elements? are you waiting for DOMContentLoaded?
– Luis Cabrera Benito
Nov 21 at 18:44
Could there be another event at play, like mouseover, click, etc. triggering a class change?
– Logan Bertram
Nov 21 at 18:45
It's not time related, nor at play, mouseover or click on it, I tried them all without inspecting the element in the console, but nothing..
– Alessandro Crotti
Nov 21 at 18:50
I believe it's time-related. Try to get them after some time usingsetTimeout
– Dominik Krzywiecki
Nov 21 at 18:57
1
stackoverflow.com/questions/28163033/…
– chrisg86
Nov 21 at 19:08
|
show 1 more comment
At what time are you getting the elements? are you waiting for DOMContentLoaded?
– Luis Cabrera Benito
Nov 21 at 18:44
Could there be another event at play, like mouseover, click, etc. triggering a class change?
– Logan Bertram
Nov 21 at 18:45
It's not time related, nor at play, mouseover or click on it, I tried them all without inspecting the element in the console, but nothing..
– Alessandro Crotti
Nov 21 at 18:50
I believe it's time-related. Try to get them after some time usingsetTimeout
– Dominik Krzywiecki
Nov 21 at 18:57
1
stackoverflow.com/questions/28163033/…
– chrisg86
Nov 21 at 19:08
At what time are you getting the elements? are you waiting for DOMContentLoaded?
– Luis Cabrera Benito
Nov 21 at 18:44
At what time are you getting the elements? are you waiting for DOMContentLoaded?
– Luis Cabrera Benito
Nov 21 at 18:44
Could there be another event at play, like mouseover, click, etc. triggering a class change?
– Logan Bertram
Nov 21 at 18:45
Could there be another event at play, like mouseover, click, etc. triggering a class change?
– Logan Bertram
Nov 21 at 18:45
It's not time related, nor at play, mouseover or click on it, I tried them all without inspecting the element in the console, but nothing..
– Alessandro Crotti
Nov 21 at 18:50
It's not time related, nor at play, mouseover or click on it, I tried them all without inspecting the element in the console, but nothing..
– Alessandro Crotti
Nov 21 at 18:50
I believe it's time-related. Try to get them after some time using
setTimeout
– Dominik Krzywiecki
Nov 21 at 18:57
I believe it's time-related. Try to get them after some time using
setTimeout
– Dominik Krzywiecki
Nov 21 at 18:57
1
1
stackoverflow.com/questions/28163033/…
– chrisg86
Nov 21 at 19:08
stackoverflow.com/questions/28163033/…
– chrisg86
Nov 21 at 19:08
|
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
It is due to the javascript console changed scope after you inspect element. Notice how top
in the first image changed to something else(mews...
) in the second image.
Your target element is probably in an iframe, or something that is not in a same javascript console scope than the top window?
I see, I didn't notice that. It's not an iframe though, I just checked the page source and no iframes at all. Besides, do you know how can I overcome this?
– Alessandro Crotti
Nov 21 at 19:16
Try clicking on thetop
, and see what causes the scope change in the list? For me it is usually eitheriframe
orextension
– William Chong
Nov 21 at 19:18
You were right, in fact there is an iframe, I just didn't see it. Thanks much for your help.
– Alessandro Crotti
Nov 21 at 20:16
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
It is due to the javascript console changed scope after you inspect element. Notice how top
in the first image changed to something else(mews...
) in the second image.
Your target element is probably in an iframe, or something that is not in a same javascript console scope than the top window?
I see, I didn't notice that. It's not an iframe though, I just checked the page source and no iframes at all. Besides, do you know how can I overcome this?
– Alessandro Crotti
Nov 21 at 19:16
Try clicking on thetop
, and see what causes the scope change in the list? For me it is usually eitheriframe
orextension
– William Chong
Nov 21 at 19:18
You were right, in fact there is an iframe, I just didn't see it. Thanks much for your help.
– Alessandro Crotti
Nov 21 at 20:16
add a comment |
up vote
1
down vote
accepted
It is due to the javascript console changed scope after you inspect element. Notice how top
in the first image changed to something else(mews...
) in the second image.
Your target element is probably in an iframe, or something that is not in a same javascript console scope than the top window?
I see, I didn't notice that. It's not an iframe though, I just checked the page source and no iframes at all. Besides, do you know how can I overcome this?
– Alessandro Crotti
Nov 21 at 19:16
Try clicking on thetop
, and see what causes the scope change in the list? For me it is usually eitheriframe
orextension
– William Chong
Nov 21 at 19:18
You were right, in fact there is an iframe, I just didn't see it. Thanks much for your help.
– Alessandro Crotti
Nov 21 at 20:16
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
It is due to the javascript console changed scope after you inspect element. Notice how top
in the first image changed to something else(mews...
) in the second image.
Your target element is probably in an iframe, or something that is not in a same javascript console scope than the top window?
It is due to the javascript console changed scope after you inspect element. Notice how top
in the first image changed to something else(mews...
) in the second image.
Your target element is probably in an iframe, or something that is not in a same javascript console scope than the top window?
answered Nov 21 at 19:11
William Chong
836416
836416
I see, I didn't notice that. It's not an iframe though, I just checked the page source and no iframes at all. Besides, do you know how can I overcome this?
– Alessandro Crotti
Nov 21 at 19:16
Try clicking on thetop
, and see what causes the scope change in the list? For me it is usually eitheriframe
orextension
– William Chong
Nov 21 at 19:18
You were right, in fact there is an iframe, I just didn't see it. Thanks much for your help.
– Alessandro Crotti
Nov 21 at 20:16
add a comment |
I see, I didn't notice that. It's not an iframe though, I just checked the page source and no iframes at all. Besides, do you know how can I overcome this?
– Alessandro Crotti
Nov 21 at 19:16
Try clicking on thetop
, and see what causes the scope change in the list? For me it is usually eitheriframe
orextension
– William Chong
Nov 21 at 19:18
You were right, in fact there is an iframe, I just didn't see it. Thanks much for your help.
– Alessandro Crotti
Nov 21 at 20:16
I see, I didn't notice that. It's not an iframe though, I just checked the page source and no iframes at all. Besides, do you know how can I overcome this?
– Alessandro Crotti
Nov 21 at 19:16
I see, I didn't notice that. It's not an iframe though, I just checked the page source and no iframes at all. Besides, do you know how can I overcome this?
– Alessandro Crotti
Nov 21 at 19:16
Try clicking on the
top
, and see what causes the scope change in the list? For me it is usually either iframe
or extension
– William Chong
Nov 21 at 19:18
Try clicking on the
top
, and see what causes the scope change in the list? For me it is usually either iframe
or extension
– William Chong
Nov 21 at 19:18
You were right, in fact there is an iframe, I just didn't see it. Thanks much for your help.
– Alessandro Crotti
Nov 21 at 20:16
You were right, in fact there is an iframe, I just didn't see it. Thanks much for your help.
– Alessandro Crotti
Nov 21 at 20:16
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53418650%2fdocument-queryselectorall-returns-values-only-after-inspecting-doms%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
At what time are you getting the elements? are you waiting for DOMContentLoaded?
– Luis Cabrera Benito
Nov 21 at 18:44
Could there be another event at play, like mouseover, click, etc. triggering a class change?
– Logan Bertram
Nov 21 at 18:45
It's not time related, nor at play, mouseover or click on it, I tried them all without inspecting the element in the console, but nothing..
– Alessandro Crotti
Nov 21 at 18:50
I believe it's time-related. Try to get them after some time using
setTimeout
– Dominik Krzywiecki
Nov 21 at 18:57
1
stackoverflow.com/questions/28163033/…
– chrisg86
Nov 21 at 19:08