HTML Compiler Online
Javascript Online Compiler
index.html
Change Theme
Compress code
Format code
Download Code
Clear Code
Copy Code!
Run
ctrl+s or click
Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Article - querySelector example 7</title> </head> <body> <h2>Select element by using querySelector.</h2> <p>If id or class of an element start with a number then used unicode value to escape it.</p> <div id="5">This is a div element with id=5</div> <button onclick="getElement()">Get element</button> <script> function getElement() { // unicode of 5 is U�035 let element = document.querySelector("#\\35"); // using double backslash to escape the escape character element.style.background = "lightgreen"; } </script> </body> </html>
Run
x
x