< a>上的jQuery悬停事件移动设备上的标记 [英] jQuery hover event on <a> tag on mobile devices

查看:75
本文介绍了< a>上的jQuery悬停事件移动设备上的标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只要不在锚元素<$ c上,jQuery .hover()事件似乎在移动设备上正常工作(在iOS 5.1 Safari上测试它) $ C>< a取代; 。正常工作意味着它会触发绑定的悬停处理程序。

The jQuery .hover() event seems to work fine on mobile devices (testing it on iOS 5.1 Safari) as long as it's not on a anchor element <a>. Work fine means it will trigger the hover handler that is bound on it.

但是,当悬停事件位于< a> ,浏览器改为从 href 的URL。

But, when the hover event is on <a>, the browser is redirected to the URL from href instead.

我希望它在第一次触摸时首先悬停(运行事件处理程序),然后再次触摸时重定向(触发点击)。有没有什么办法做到这一点?

I want it to hover first on first touch (run the event handler) before it's being redirected (trigger the click) on second touch. Is there any way of doing this?

推荐答案

您必须添加一个事件处理程序到改变DOM的链接切换类以改变背景颜色等)

You must add an event handler to the link that changes something about the DOM (like toggling a class to change background colors, etc.)

Mobile Safari文档

From the Mobile Safari docs:


鼠标事件按照您在图6-4中所示的其他web
浏览器中预期的相同顺序传递。如果用户点击不可点击的
元素,则不会生成任何事件。如果用户点击可点击的
元素,则按以下顺序到达:mouseover,mousemove,mousedown,
mouseup,然后单击。只有当用户点击
另一个可点击项目时,才会出现鼠标移出事件。另外,如果页面的内容在
变为mousemove事件时发生,则不会发送序列中的后续事件。
此行为允许用户点击新内容

这篇关于&lt; a&gt;上的jQuery悬停事件移动设备上的标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆