Attempting To Use Jquery To Change An Img Src Of Draggable Object When Dropped
Basically, I have .dragme (object being dragged), .dropzone1 (place to be dropped at) and an image I want .dragme to become once it has been dropped. So far I have this $('.dropzon
Solution 1:
Try this:
$(".dragme").draggable();
$(".dropzone1").droppable({
accept:".dragme",
drop: function( event, ui ) {
$(".dragme").attr("src", "../imgs/newimage.png");
alert($(".dragme").attr('src'));
}
});
2nd Solution
$(".dragme").draggable();
$(".dropzone1").droppable({
accept:".dragme",
drop: function( event, ui ) {
$(ui.draggable).attr("src", "../imgs/newimage.png");
}
});
From the drop event documentation:
This eventis triggered when an accepted draggable is dropped 'over' (within the
tolerance of) this droppable. In the callback, $(this) represents the droppable
the draggable is dropped on. ui.draggable represents the draggable.
Post a Comment for "Attempting To Use Jquery To Change An Img Src Of Draggable Object When Dropped"