首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jQuery脚本翻转在iDevices上不兼容

jQuery脚本翻转在iDevices上不兼容
EN

Stack Overflow用户
提问于 2013-12-13 17:56:37
回答 1查看 65关注 0票数 0

我有一个jQuery脚本来管理我的图像的滚动。我的脚本在PC上运行良好,但不幸的是,这个脚本与iDevices (iPad,iPhone)不兼容。

image-normal.jpg <=> image-hover.jpg

你能帮帮我吗?

代码语言:javascript
复制
$(document).ready(function(){
  $(function () {
    $('img.rollover').hover(function () {
      $(this).css("cursor", "pointer");
      this.src = this.src.replace("-normal","-hover");
    }, function () {
      this.src = this.src.replace("-hover","-normal");
    });
  });
});
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-13 18:02:49

试试这个:

代码语言:javascript
复制
$(document).ready(function(){
    $(function () {
        $('img.rollover').on('mouseenter touchstart', function(){
            $(this).css("cursor", "pointer");
            this.src = this.src.replace("-normal","-hover");
        });

        $('img.rollover').on('mouseleave touchend', function(){
            this.src = this.src.replace("-hover","-normal");
        });
    });
});

您仍然需要触摸(点击)移动图像,因为没有悬停。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20572972

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档