Monday, 26 August 2013

get div id when an object is dropped using jquery

get div id when an object is dropped using jquery

I want to get the div id of the dragged item when it is dropped to a div.
My problem is , when I dropped it into the layer 3, it also reads the
layer 1 and layer 2. What I want is only the layer 3 since it is hovered.
please consider the code below.
Thanks in advance.
<div>
<img class="item" src="img.jpg"/>
</div>
<div id="layer1" class="droppable" style="width:100px; height : 100px ;">
<div id="layer2" class="droppable" style="width:70px; height : 70px; ">
<div id="layer3" class="droppable" style="width:50px; height: 50px">
Drop an image here
</div>
</div>
</div>
<script>
$(function(){
$(".droppable").droppable({ accept : 'item' , drop : Calldropp });
function Calldropp (){
<!-- what to do here -->
}
})
</script>

No comments:

Post a Comment