Assume you have a valid HTML element in DOM. I assumed the following snippets to be the same. let id = "037e3778-e157-4715-bff5-e466230fe7a3" const byId = document.getElementById(id) console.log(byId) // works const bySelectorConcat = document.querySelector("#" + id) console.log(bySelectorConcat) // Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '#037e3778-e157-4715-bff5-e
![Difference between getElementByID and querySelector](https://cdn-ak-scissors.b.st-hatena.com/image/square/9e6d6538e716c7800ae89cf5c5d752ebde6d53a6/height=288;version=1;width=512/https%3A%2F%2Fkiru.io%2FTwitterCard.png)