Search code examples
jqueryjquery-uijquery-ui-droppable

jQuery UI draggable and drop


I am creating a jQuery UI drag and drop . I likes to change the class of dragged object as soon as that element is dropped on the destination. Is there is any way for that ? My code looks like follows

$('.tech_new').draggable({ revert: "invalid" });



$( "#droppable" ).droppable({
        drop: function( event, ui ) {

        var id=ui.draggable.attr('id');
                    alert(id);
                    $('.tech_new').fadeOut(5000);
        }
    });

Now I can drag and drop the "tech_new" to the "droppable" . After droping I need to change the droped elements class ( ie tech_new's class )


Solution

  • You can always store the ID of the dragged object somewhere in memory and then when the item is dropped you can fetch the element and change it's class.