【问题标题】:call function after dragging in jqueryjQuery拖入后调用函数
【发布时间】:2012-04-28 02:07:13
【问题描述】:

我正在尝试调用一个函数以在拖动 div 后检查它的位置,但我不确定如何使其工作。我已经像这样和其他一些方式写了它,但它要么导致整个事情不起作用,要么函数没有被调用:

$(".block").draggable(),function() { check(); };

有没有简单的方法来完成这项工作?

【问题讨论】:

    标签: jquery syntax


    【解决方案1】:

    有一个名为stop 的事件。你可以在这里阅读:http://jqueryui.com/demos/draggable/#event-stop

    停止拖动后获取被拖动元素位置的示例代码如下:

    $(".block").draggable({
        stop: function(event, ui) {
            var pos = ui.helper.position(); // just get pos.top and pos.left
        }
    });
    

    在此处查看有效的解决方案:http://jsfiddle.net/rcmyy/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-07
      • 1970-01-01
      • 1970-01-01
      • 2010-10-01
      相关资源
      最近更新 更多