News for hackers. Stuff that matters.

webnoob

Re:Introducing command And commandfor In HTML on Friday March 07, 2025 @03:40PM (#43294352)
I'm curious, as a noob in web programming. That first example does

    document.addEventListener('click', ...
Instead of

    someButton.addEventListener('click', ...
And in fact, all the framework example show button onClick not document onClick

I know some situations where adding the event listener to the document is correct but I've never seen it in this button type situation.

Is that pattern for buttons common? What does it solve?