如何在没有警报框的情况下对此行为进行编码?解决方案以下是解决此问题的好方法:触发点击并保持事件 http://jsfiddle.net/VXbpu/1/ http://jsfiddle.net/vPruR/70/ var click = false;$(document).bind('mousemove', function (e) { if (click == true) { $('#your_div_id').css({ left: e.pageX, top: e.pageY }); }});$('#your_div_id').click(function() { click = !click; return false;});$('html').click(function() { click = false;});I am trying to drag an element without keeping the mouse button down.The behavior I would like is :I click on a draggable itemDrag my item without keeping mouse left click down : just follow the mouse as a cursorI click on a droppable container to confirm and append my itemI am able to simulate this behavior if I add an alert box durring the start event. start : function(){ alert('test') },Here is the fiddle : http://jsfiddle.net/QvRjL/103/How is it possible to code this behavior without the alert box? 解决方案 Here is a good solution about this problem : Trigger Click-and-Hold Eventhttp://jsfiddle.net/VXbpu/1/http://jsfiddle.net/vPruR/70/var click = false;$(document).bind('mousemove', function (e) { if (click == true) { $('#your_div_id').css({ left: e.pageX, top: e.pageY }); }});$('#your_div_id').click(function() { click = !click; return false;});$('html').click(function() { click = false;}); 这篇关于jQuery ui拖动元素,而无需按住鼠标键(跟随光标)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!