you want to use the dollar sign $
to select HTML elements but you don't want to use Jquery ?
All you need to do is this:
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document)
Now let say we have a div with the class container
, you can select it like this:
const container = $(".container");
Now lets say we have multiple inputs with the class input
and we want to select all of them, you can do it like this.
const inputs = $$(".input");
If you found this post useful give it a like.
Top comments (0)