简体   繁体   中英

How to distinguish between mouseenter and tap events?

If you have a mouseenter event, touch-enabled devices will trigger this event when user taps the element.

How to distinguish between a genuine (physical) mouse enter event and a tap (mouse enter simulation)?

You could check if the user is visiting your website from a mobile device:

if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) 
    // do something
else
    // do something else

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