如何在javascript中捕捉dragend事件?
问题描述:
我想抓住一个可拖动DIV的JavaScript dragend事件。 dragend事件根本没有被解雇,为什么?以及如何解决这个问题? PS,我尤斯.draggable()方法:jQuery UI的1.9.2如何在javascript中捕捉dragend事件?
这里是我的代码:http://jsfiddle.net/vBMav/
HTML:
<div id="divId"> ... </div>
CSS:
#divId {
background-color: #000000;
color: #ffffff;
height: 200px;
width: 200px;
}
Javascript:
$('#divId').draggable();
$('#divId')
.bind('dragstart', function(){ $("#divId").text("drag start"); })
.bind('drag', function(){ $("#divId").text("dragging"); })
.bind('dragend', function(){ $("#divId").text("drag ended"); });
答
尝试使用 'dragstop' 而不是 'dragend'
.bind( 'dragstop',函数(){$( “#DIVID”)文本( “拖动结束”);});
它的工作原理!他们之间有什么区别? – 2013-02-27 14:15:06
这是写在文档中的正确用法:http://api.jqueryui.com/draggable/ – Jacob 2013-02-27 14:18:09
在jQuery文档中,true,但为什么不jQuery使用'dragend'事件,就我而言“dragstop”不是“HTML5”标准吗? – 2015-03-05 21:28:05