loading...

re: Use $ & $$ Instead of document.querySelector/All in JavaScript without jQuery VIEW POST

FULL DISCUSSION
 

I'm using document.querySelectorAll for all elements. Even for id elements.

Actually, you can use querySelectorAll for id elements. It will work for one element. There must not be multiple elements in a document that have the same id value.

const $ = document.querySelectorAll.bind(document)

const testEl = $("#test")

testEl.forEach(el => {
    console.log(el)
})
Code of Conduct Report abuse