【问题标题】:Iphone click event on position fixed固定位置上的Iphone点击事件
【发布时间】:2017-05-26 01:07:27
【问题描述】:

我有问题,我有固定位置的元素,点击后我启用模式: Here is demo

JS:

$(document).on('click', '.open', function(){
    $(this).toggleClass('active');
});

$(document).on('click', '.modal, .modal-close', function(){
    $('.open').removeClass('active');
});

$(document).on('click', '.modal-content', function(e){
    e.stopPropagation();
});

在点击圈上,我使用 jquery 打开模式,在 android 上这工作正常,但 iPhone 没有检测到点击事件。我该如何修复它?

【问题讨论】:

    标签: jquery iphone click fixed


    【解决方案1】:

    Updated fiddle.

    尝试将touch也添加到事件中:

    $(document).on('click touch', '.open', function(){
        $(this).toggleClass('active');
    });
    
    $(document).on('click touch', '.modal, .modal-close', function(){
        $('.open').removeClass('active');
    });
    
    $(document).on('click touch', '.modal-content', function(e){
        e.stopPropagation();
    });
    

    并尝试将cursor:pointer 添加到open 元素:

    .open{
        cursor:pointer;
    }
    

    或者来自js代码:

    $('.open').css('cursor','pointer');
    

    希望这会有所帮助。

    【讨论】:

    • jsfiddle.net/55v2Lvkp/7 现在它就像焦点一样,如果我保持联系,请查看演示
    • 好的,在 android 上工作,但在 iphone 上这个圆形按钮不起作用:/
    • 我没有 iPhone,但它在模拟器中运行良好。不知道为什么会这样。
    猜你喜欢
    • 2012-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多