jquery - 如何在设备上使用可拖动功能

标签 jquery mobile draggable

我使用了jquery的可拖动功能。

<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<script>
$('.div').draggable(); 
</script>
<body>
<div class="div">
Text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. 
</div>
</body>

以上引用适用于桌面设备,但不适用于移动设备或 iPad。

最佳答案

jQuery UI 用户界面库当前不支持使用触摸事件。这意味着您在桌面浏览器中设计和测试的 UI 将在大多数(如果不是全部)支持触摸的移动设备上失败,因为 jQuery UI 监听鼠标事件(如 mouseover、mousemove 和 mouseout)而不是触摸事件(touchstart、 touchmove 和 touchend)。

你可以尝试jQuery UI Touch Punch 。它可能会执行您所要求的操作,但请注意:

Touch Punch is a hack. It duck punches some of jQuery UI's core functionality to handle the mapping of touch events. Touch Punch works with all basic implementations of jQuery UI's interactions and widgets. However, you may find more complex cases where Touch Punch fails.

关于jquery - 如何在设备上使用可拖动功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25310126/

相关文章:

jquery - 多个绑定(bind)(将绑定(bind)添加到已绑定(bind)的父 View 中的分部 View )

css - jQuery Mobile - 页脚 - 导航栏 - 当渲染显示为三列和两行网格布局时

javascript - Nativescript:如何从图库获取照片列表

jquery - IE8 - 在可拖动的 div 中带有 flash 的 iframe - 糟糕的重绘

Jquery Colorbox 具有可拖动事件?

javascript - jQuery Accordion DOM

jquery - 物化CSS |使用多选,无法预选所有选项

wpf - 适用于电脑和手机的应用程序

javascript - 忽略鼠标悬停目标?

javascript - 切换显示/隐藏 (jQuery)