我使用了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/