Hacker News new | ask | show | jobs
by rictic 237 days ago
A click handler can be doing a lot of things that aren't much like a button, like letting you close a modal if you click outside of it, capturing mouse events for a game, or passively recording events for analytics. All that a click handler tells you is that there's some code that sometimes cares about some clicks somewhere inside that element.
2 comments

Also a click handler on a div isn't going to do much for someone who isn't using a mouse, which would include a lot of screen reader users.
All of those seem like examples of things you’d want your screen reader to tell you about.
Sure.

What is the screen reader's plan for determining the purpose of the attached JavaScript?

Same as a button. Read the text in the element. If no text, skip it or say "clickable".

I'm not arguing a div is better. I'm just saying screen readers could announce a div with an onclick if they wanted to.