拖動

2013-10-29 30 views
1

後檢測鼠標鬆開我的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

使用stop:在jQuery UI的例子

$('.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'); 
    } 

}); 

瞭解更多關於stop和可拖動的活動:http://jqueryui.com/draggable/#events

+0

真棒,感謝隊友:) – colmtuite