我有jQuery UI draggable在元素上工作。

当拖动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
    }

});

最佳答案

使用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

10-07 14:07
查看更多