1

我有 jQuery UIdraggable在一个元素上工作。

elementA被拖动时,我正在从elementB.

我想要检测何时elementA停止拖动,并将类添加回elementB.

$('.container').draggable({

    // Output offset while dragging box
    drag: function(){

        $('.properties').removeClass('appear');

        // Detect mouseup after dragging has stopped
        // and add .appear back to .properties
    }

});
4

1 回答 1

1

使用stop

$('.container').draggable({

  // Output offset while dragging box
  drag: function(){

    $('.properties').removeClass('appear');

    // Detect mouseup after dragging has stopped
    // and add .appear back to .properties
  },
  stop: function() {
    // Add your class back to elementB here.
    $('.properties').addClass('appear');
  }

});

在 jQuery UI 示例中阅读有关stop和 Draggable 事件的更多信息:http: //jqueryui.com/draggable/#events

于 2013-10-29T03:23:13.357 回答