繁体   English   中英

Chrome 中的禁用按钮仍会在触摸时触发

[英]Disabled button still fires on touch in Chrome

在 Chrome 浏览器中,我注意到在使用“touchend”或“pointerup”事件时,禁用的按钮元素仍在触发。 我在设备仿真模式下的 Chrome 桌面 (mac) 和 Surface 上的 Chrome 中看到了这一点。 这在其他浏览器上似乎不是问题。

// neither of these seem to have an effect on touch/pointer events
button.disabled = true;
button.setAttribute('disabled', 'disabled');

明显的修复只针对鼠标事件,但我宁愿没有延迟时间让它在触摸设备上触发。 我假设这是一个 Chrome 问题,而不是我的代码,但我想我想看看可能是我,或者其他人是否找到了实用的解决方法。

我遇到了同样的问题,正如@bigless 所建议的那样,CSS 下面也对我有用。

button:disabled { pointer-events: none };

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM