【问题标题】:Dragstop on JQueryjQuery 上的 Dragstop
【发布时间】:2016-10-01 10:22:39
【问题描述】:

我使用 JQuery 来识别 dragstart 和 dragstop。 dragstart 事件运行良好,但 dragstop 事件没有。 这是我写的代码-

$('img').on('dragstart', function (event) {
	$(function() {		      
            $("#toolbar").animate({width:'toggle'},0);      
		});
		
});
$('img').on('dragstop', function (event) {
		alert("hi");	
});

谢谢。

【问题讨论】:

    标签: javascript jquery drag-and-drop drag


    【解决方案1】:

    使用dragend 事件! 在拖动操作结束时触发

    所有事件请参考HTML Drag and Drop API

    $('#image').on('dragstart', function(event) {
      console.log('dragstart');
    });
    $('#image').on('dragend', function(event) {
      console.log('dragend');
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <img src="https://www.repeatsoftware.com/Help/img3C.gif" id="image" height="100px" width="100px" />

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-26
      • 2015-02-25
      • 2011-06-25
      • 2012-03-28
      • 1970-01-01
      相关资源
      最近更新 更多