简体   繁体   中英

click event for touch devices instead hover event

I'm trying to create a slideshow with jQuery like kwicks slider. so I use hover function to set my animation to do. but in touch devices hover functions doesn't perform in all browsers. In chrome and opera and firefox when I click on the slide its animation starts and keep moving to its ending time. but in ie and edge my hover animation starts with touchstart and ends right the moment touchend occurs. so animation doesn't keep forward to its end and goes back into its initial position. So I decided to use click event together with hover event like this:

slides.hover(function(){
// my animation code
}
slides.click(function(){
// the same animation code
}

but hover and click animation codes overwrite each other and my desturies my animations. does anyone any idea to help me at this?

Please note that ie doesn't support touch events. So I need a trick on click and hover events.

您可以尝试ontouchstart事件,它将成功解决问题。

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