简体   繁体   English

iPad Safari悬停事件

[英]Hover event for iPad Safari

I have a page with "main tabs" which behaves as follows; 我有一个带有“主要标签”的页面,其行为如下: 1. On hover of these, I show "sub tabs" 2. On click of any of the main tabs, it goes to one of the default sub tab pages. 1.将鼠标悬停在这些选项卡上,然后显示“子选项卡”。2.单击任何一个主选项卡后,它将转到默认的子选项卡页面之一。

$(".mainlink_href").mouseover(function(){...}

Now these behaves as expected on desktop browsers. 现在,它们在台式机浏览器上的行为符合预期。 But on the iPad, when user clicks on any of the main tabs, it always does the hover method execution ie shows the sub tabs and does not go the sub tabs page (as in the desktop) 但是在iPad上,当用户单击任何主选项卡时,它总是执行悬停方法,即显示子选项卡,而不进入子选项卡页面(如在桌面上)

Now I agree, that this is as per expected iPad behavior since there is no mouse cursor to track for hover event otherwise... 现在我同意,这与预期的iPad行为相同,因为没有鼠标光标可以跟踪悬停事件,否则...

But is there any way that I can update the code such that "only for the iPad" it does not go through the hover method for the first click and instead does the click event and directly takes the user to the default sub tab page (ie similar to point 2 above in desktop browsers) 但是,有什么方法可以更新代码,以使“仅适用于iPad”在第一次单击时不会通过悬停方法,而是会单击事件并将用户直接带到默认子选项卡页面(即类似于桌面浏览器中的上述第2点)

Please help me. 请帮我。 Thank you. 谢谢。

You could just assign both event handlers, and have the ontouchstart handler remove the onmouseover handler. 您可以只分配两个事件处理程序,并让ontouchstart处理程序删除onmouseover处理程序。

$(".mainlink_href").mouseover(function(){...});
$(".mainlink_href").ontouchstart(function(){this.mouseover=function(){};});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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