How to select the droppable element 'on drop' ? (beginner)
Hi,
I have a grid of multiple divs and a drag item. I'm trying to get the position of the cell where the drag item is dropped. So how to select the element where the drag elements is dropped on so I can determine the position of this element, and append the drag item to it with a nice animate()?
This is the jquery code I have so far:
- $(function() {
-
- $('.drag').draggable();
- $('.cell').droppable({
- drop : function() {
- var offset = $('.cell').offset();
- alert( "left: " + offset.left + ", top: " + offset.top );
- }
- });
-
- });
HTML:
- <div id="raster">
- <div class="cell"></div>
- <div class="cell"></div>
- <div class="cell"></div>
- <div class="cell"></div>
- <div class="cell"></div>
- <div class="cell"></div>
- <div class="cell"></div>
- </div>
- <div class="drag"></div>
Using this code I only get the position of the first droppable cell :-(
Can someone help me plz?
Thanks!
Christophe