2014-10-01 26 views
0

我目前有一系列图像,当在桌面上激活onmouseover时,它将在其位置显示另一图像。这适用于所有台式机,手机和平板电脑浏览器 - 除iPad Safari/Chrome上的横屏外。onmouseover不适用于iPad风景,Safari或Chrome

我主要感到困惑,因为它在人像中工作正常,但是一旦将iPad更改为风景 - 在图像上点击不起作用。我们也有一个脚本,可以更新方向更改页面,但我认为这不会引起任何问题。如果我错了,请纠正我。

这里是我们的代码摘录:

<img src="/getmedia/b69c7c54-e84e-486d-b9fb-b89644b0c7fe/Claire-1.jpg?width=224&amp;height=224&amp;ext=.jpg" alt="Claire" title="Claire" class="team-member-static4" onmouseover="jQuery(this).attr('src','/getmedia/6abe9a6f-0144-470e-8dc5-3124c1446642/Claire-2.jpg?width=224&amp;height=224&amp;ext=.jpg').stop.toggle();" onmouseout="jQuery(this).attr('src','/getmedia/b69c7c54-e84e-486d-b9fb-b89644b0c7fe/Claire-1.jpg?width=224&amp;height=224&amp;ext=.jpg');"> 

非常感谢。

+0

确定的图像没有被覆盖的另一个元素? Z指数的问题?此外,如果您可以提供帮助,则不应将其与内容一起使用。 – evu 2014-10-01 09:43:39

+0

http://stackoverflow.com/search?q=mouseover+mobile - 例如http://stackoverflow.com/questions/4755505/how-to-recognize-touch-events-using-jquery-in-safari-for -ipad-is-it-possible-PS如何不使用内联代码。无法阅读 - 也缩短了网址 – mplungjan 2014-10-01 09:43:39

+0

我真的不认为阅读mplungjan是不可能的,但是感谢您的宝贵意见。我没有亲自写这段代码,其中一位开发人员做了 - 但我现在负责寻找解决方案。没有z-index问题,我可以看到evu。 – 2014-10-01 09:59:23

回答

0

它看起来是这样的:

var claire = {} 
$(function() { 
    claire.$img = $("img[alt='Claire']"); 
    claire.on=claire.$img.data("on")+'?width=224&amp;height=224&amp;ext=.jpg'; 
    claire.off=claire.$img.attr("src"); 
    claire.$img.on('mouseover touchstart',function(){ 
    $(this).prop("src",claire.on) // .stop.toggle(); // why toggle? 
    }) 
    .on('mouseout touchend',function(){ 
    $(this).prop("src",claire.off); 
    }); 

使用

<img src="/getmedia/b69c7c54-e84e-486d-b9fb-b89644b0c7fe/Claire-1.jpg?width=224&amp;height=224&amp;ext=.jpg" 
alt="Claire" title="Claire" class="team-member-static4" 
data-on="/getmedia/b69c7c54-e84e-486d-b9fb-b89644b0c7fe/Claire-1.jpg" /> 
相关问题