DEV Community

How to use jQuery CSS selectors in vanilla JavaScript ?

Justin Ethier on May 06, 2022

One of the best features of jQuery is the use of CSS selectors to reference elements, EG: $('#my-id').

How can I use selectors when writing vanilla JavaScript?

Collapse
 
nestedsoftware profile image
Nested Software • Edited

I think you're looking for document.querySelector or document.getElementById etc

developer.mozilla.org/en-US/docs/W...

developer.mozilla.org/en-US/docs/W...