简体   繁体   English

如何判断是否使用jQuery拖动了元素?

[英]How can I tell if an element is being dragged using jQuery?

How can I check if an element is being hovered over and/or clicked on and/or dragged? 如何检查元素是否悬停和/或单击和/或拖动? I need this info so I can stop infinite loops for the duration of the drag. 我需要此信息,以便可以在拖动期间停止无限循环。

You can use jQuery UI's Draggables feature. 您可以使用jQuery UI的Draggables功能。 It allows you to set a callback function for when the drag starts. 它允许您设置拖动开始的回调函数。 Documentation is at http://jqueryui.com/demos/draggable/#event-start . 文档位于http://jqueryui.com/demos/draggable/#event-start It also has a callback for during a drag. 在拖动过程中,它也有一个回调。

You can already set callback functions for hover and click via jQuery's click() and mouseover() events. 您已经可以为悬停设置回调函数,并通过jQuery的click()和mouseover()事件进行单击。 http://docs.jquery.com/Events http://docs.jquery.com/事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM