简体   繁体   中英

Disabled button still fires on touch in Chrome

In the Chrome browser, I noticed disabled button elements are still firing when using 'touchend' or 'pointerup' events. I see this on Chrome desktop (mac) in device emulation mode and in Chrome on a Surface. This doesn't seem to be problem on other browsers.

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

Obvious fix would to only mouse events, but I'd rather not have the lag time for it to trigger on touch devices. I'm assuming this a Chrome issue and not my code, but I thought I'd ask to see maybe it is me or if others have found a practical work around.

I was facing same problem and as suggested by @bigless, below CSS worked for me too.

button:disabled { pointer-events: none };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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