<h2 id="example/123">A heading</h2>
<script>
document.querySelectorAll("#example/123");
</script>
Any idea why above id is not working? do I need extra library to escape the /?
<h2 id="example/123">A heading</h2>
<script>
document.querySelectorAll("#example/123");
</script>
Any idea why above id is not working? do I need extra library to escape the /?
You can escape the / using \\.
<h2 id="example/123">A heading</h2>
<script>
document.querySelectorAll("#example\\/123");
</script>
Duplicate of CSS selector to select an id with a slash in the id name?
However in this case you are using an id, so you can get the specific element without needing to get it from the NodeList using document.getElementById(), as only one element should have that id.
document.getElementById("hello/world");