Reputation: 4082
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 )
Upvotes: 0
Views: 138
Reputation: 171
There is a jQuery function just for this.
$('.classyouwanttochange').removeClass().addClass('newclassname');
Upvotes: 1
Reputation: 695
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.
Upvotes: 0