Skip to content
Advertisement

How to change a event listener from hover to click depending on device width on javascript

i am facing issue on jquery while using hover listener event, the code is just working on desktop while on mobile i can’t get it to work with the hover listener.So i just wanna implement click function instead of hover when the site is being displayed on mobile and hover on pc/laptop.I am sharing my code below. Also i am using blastjs and animate.css for text animation.

Header Element for the animation

JavaScript

Jquery Code

JavaScript

Advertisement

Answer

You can check the device width before making the event listener

JavaScript

}); });

If the screen.width was not suitable, you can find some ways to detect the device type on this discussion

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement