【问题标题】:mouseover effect in touch devices触控设备中的鼠标悬停效果
【发布时间】:2014-07-30 10:34:09
【问题描述】:

我正在尝试弄清楚如何在触摸设备中实现“鼠标悬停”效果。

我创建了这个简单的示例来演示我正在寻找的行为。

$( document ).ready(function() {
    isDown = false;

    $('#rect1').on('touchstart mousedown', function(e) {
        e.stopPropagation();
        e.preventDefault();

        isDown = true;

        $(this).css({"background-color":"red"});
    });

    $(document).on('touchend mouseup', function(e) {
        e.stopPropagation();
        e.preventDefault();

        isDown = false;

        $('#rect1').css({'background-color':'grey'});
        $('#rect2').css({'background-color':'grey'});
    });

    $('#rect2').on('touchmove mouseover', function(e) {//.hover(function() {
        if (isDown) {
            $(this).css({"background-color":"red"});
        }
    });
});

http://jsfiddle.net/mE9Ug/

我想在移动设备(触摸设备)上实现相同的行为。

如您所见(在示例中),touchmove 不起作用。我还尝试了 jquery mobile 的 vmouseover,但效果不佳。

如果有人有任何想法,我真的很感激!

谢谢, 阿萨夫

【问题讨论】:

  • 如果你能够检查控制台,那么首先你应该检查你的控制台错误..我确定控制台错误会破坏你的悬停效果......
  • 什么意思?在我的手机中,我没有控制台选项,桌面版本也没有错误。

标签: jquery html jquery-mobile mobile touch


【解决方案1】:
猜你喜欢
  • 2011-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-05
  • 2014-09-30
  • 2017-07-02
  • 2013-11-23
相关资源
最近更新 更多