Comment

Comment by webnoob

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?

parent webnoob 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton