DEV Community

Justin Ethier
Justin Ethier

Posted on • Edited on

1 1

How to use jQuery CSS selectors in vanilla JavaScript ?

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?

Top comments (1)

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...

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs