Categories
JavaScript Answers

How to use querySelector with IDs that are numbers with JavaScript?

Spread the love

To use querySelector with IDs that are numbers with JavaScript, we add '#\\3' before the number.

For instance, we write

const el = document.querySelector("#\\31 ");

to select the element with ID 1 with querySelector.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *