Here is an idea of what I’m trying to do – a custom shorthand:
on_cl('#id' /* or .class instead of #id */){
// insert code here
}
, to not paste this over and over:
document.querySelector('#id' /* or .class */).addEventListener('click', () => {
// insert code here
})
. Basically, these 2 chunks of code should be equivalent.
How can I do this?
I searched for an answer on MDNdocs, but didn’t find what I wanted.