3 ms·
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 f
by rictic 11mo 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.
- knute 11mo agoAlso 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.
- randyrand 11mo agoAll of those seem like examples of things you’d want your screen reader to tell you about.
- zahlman 11mo agoSure. What is the screen reader's plan for determining the purpose of the attached JavaScript?
- randyrand 11mo agoSame 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.