javascript - Targetting specific div through class with jquery draggable/droppable -
when dragging div using jquery ui , dropping ui droppable div, want trigger jquery animation on div being dropped area. when animation triggered, called on divs class = "drag-element" want specific dragged , dropped element animated. have tried including removeclass(".drag-element") , addclass(".animate-element") , telling animate() act on still applying animation .drag-element divs. how do fix this?
jquery:
$(function() { $( ".drag-element" ).draggable({ containment: ".container" }).removeclass(".drag-vid"); $( ".drop-field" ).droppable({ drop: function( event, ui ) { $(".drag-element").animate({"left": "+=50px"}, "slow"); $( ) .css("background-color", "silver"); } }); });
use:
ui.draggable.animate({"left": "+=50px"}, "slow");
instead of:
$(".drag-element").animate({"left": "+=50px"}, "slow");
what happened code when call $(".drag-element").animate(....
selects drag-element divs. instead drop function has ui argument provides information dragged element using ui.draggable
Comments
Post a Comment