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