Created
June 20, 2019 23:09
-
-
Save natevw/43219674e93dfacc863645c411797a83 to your computer and use it in GitHub Desktop.
Testing whether querySelectorAll finds multiple elements with #non_unique id.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html><head> | |
<meta charset="utf-8"> | |
<title>Testing multiple ids</title> | |
</head><body> | |
<p id="one"> | |
<span id="not_unique">One</span> | |
</p> | |
<p id="two"> | |
<span id="not_unique">Two</span> | |
</p> | |
<script> | |
let docResults = document.querySelectorAll('#not_unique'), | |
divResults = document.querySelectorAll('#two #not_unique'), | |
divResults = document.getElementById('#two') #not_unique'), | |
document.write(`doc: ${docResults.length}, div: ${divResults.length}`); | |
console.log({docResults,divResults}); | |
</script> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment