【问题标题】:Jquery click event not working on li in devices(ipad, iphone..)Jquery单击事件在设备(ipad,iphone ..)中的li上不起作用
【发布时间】:2013-10-16 05:56:04
【问题描述】:

Jquery 点击事件在设备中的 li 上不起作用。我尝试使用 click 和 touchstart 事件,但是使用 touchstart 时的问题是我无法向下滚动 div。当我尝试通过单击 li 向下滚动时,它被选中。有没有办法使用任何 jquery 事件而不是 jquery 移动事件来选择和滚动 li?

$('#liId').on({ 'touchstart' : function(){ console.log('Event Fired'} });

【问题讨论】:

  • 试试$('#liId').on( 'touchstart', function(){ console.log('Event Fired'); });
  • 事件被触发,但问题是我无法向下滚动。
  • 试试这个例子jsfiddle.net/coma/9KvhL/25

标签: jquery events scroll


【解决方案1】:

当我为所有的li添加一个样式类时,问题就解决了。

.liClass { 光标:指针; }

【讨论】:

    【解决方案2】:

    : 替换为, 并在“touchstart”之前解开{}

    $('#liId').on( 'touchstart', function(){ 
     console.log('Event Fired');
    });
    

    【讨论】:

    • 好吧,我也试过了...我收到了事件,但我无法滚动 div。当事件被触发时,触发 touchstart 事件的 li 被选中。
    • @ABHILASHSB 检查该项目的 css。我怀疑问题是否存在
    【解决方案3】:

    在你的css文件中

    #liId { cursor : pointer; }
    

    jQuery

    $('#liId').click(function(){
        alert('Event Fired');
    });
    

    【讨论】:

      猜你喜欢
      • 2023-01-12
      • 2015-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-14
      相关资源
      最近更新 更多