拖动后检测鼠标

时间:2013-10-29 02:41:34

标签: javascript jquery jquery-ui

我有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
    }

});

1 个答案:

答案 0 :(得分: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