jQuery mouse's .click() is launched by keyboard navigation

99封情书 提交于 2019-12-05 09:54:48

Yes, this is normal. The JQuery documentation is correct, but a bit incomplete. There's more details on the WC3 site - eg:

Note: For maximum accessibility, content authors are encouraged to use the click event type when defining activation behavior for custom controls, rather than other pointing-device event types such as mousedown or mouseup, which are more device-specific. Though the click event type has its origins in pointer devices (e.g., a mouse), subsequent implementation enhancements have extended it beyond that association, and it can be considered a device-independent event type for element activation.

Or, put another way, for some elements, click() is essentially a logical event rather than a device-specific event.

If you really want to only respond to mouse input, you can use the mousedown/up events - but keep in mind you'll then have to make your UI keyboard accessible separately (eg. using keydown/press/etc events to provide a keyboard equivalent).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!