Mousedown活动与ipad / iphone兼容? – jQuery Mobile

我在jquery中写了一个小卷轴。 滚动条似乎在PC和Mac上完美运行。 但是它不适用于触控设备。

我想这是因为mousedown属性被调用。 如何在PC和触摸屏设备上完成这项工作?

谢谢

 $('.scroll-nav-up, .scroll-nav-down').live('click', function(){ $('.scroller-wrap').stop(); return false; }); $('.scroll-nav-up').live('mousedown', function(){ $(this).closest('.item').find('.scroller-wrap').animate({ top: -($(this).closest('.item').find('.scroller-wrap').height() - 250) }, 800); }); $('.scroll-nav-down').live('mousedown', function(){ $(this).closest('.item').find('.scroller-wrap').animate({ top: 0 }, 800); }); 

如果你正在使用jquery mobile尝试处理它的新事件taptaphold

http://jquerymobile.com/demos/1.0a2/#docs/api/events.html

我无法测试它,所以这只是一个想法(我不确定我是否理解你的应用程序的function),但你可以尝试更改click to mouseup事件。

没有什么特别的,所以此刻我正在使用2个脚本。 第一个脚本识别Alastair Campbell在检测基于触摸的浏览时所写的触摸屏设备。

 function isTouchDevice() { var el = document.createElement('div'); el.setAttribute('ongesturestart', 'return;'); if(typeof el.ongesturestart == "function"){ return true; }else { return false } } 

然后将mousedown事件用于常规浏览器并对触摸屏设备使用tap事件。

PS – 使用jQuery和jQuery Mobile