Skip to content

DOMException: Failed to execute 'querySelector' on 'Document' #12

Answered by amaitland
saddomik asked this question in Q&A
Discussion options

You must be logged in to vote

What am I doing wrong?

As per the error message, your selector (#1461173234025-3129f8602eccbe259104553afa8415434b4581-02de_1461173234023-2568f8602eccbe259104553afa8415434b458-10ad) is not valid in the context of document.querySelector.

Run the following in the DevTools Console and you'll get the same exception.

document.querySelector('#1461173234025-3129f8602eccbe259104553afa8415434b4581-02de_1461173234023-2568f8602eccbe259104553afa8415434b458-10ad');

Whilst the ID is valid, a CSS Id selector cannot start with a number. See https://stackoverflow.com/a/37271406/4583726 for more detail.

You'll need to use document.getElementById instead. There is no API method for that yet as querySelecto…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by amaitland
# for free to join this conversation on GitHub. Already have an account? # to comment
Category
Q&A
Labels
None yet
2 participants