0

I'm making a jigsaw puzzle in HTML. There's a table which has empty spaces and below the table there are pieces which fit exactly into the empty spaces.

So I know how to get the draggable and droppable element on drop and how do get the draggable element on drag. But how do I get the droppable element in which the draggable element currently resides on drag event. Also if a draggable element isn't inside a droppable element it shouldn't break the code.

http://altement.ee/overflow/ click on on a button to start the puzzle too see what I have made. I need to know in which droppable element it is in right now to know if it is in a correct spot already or not.

Alo
  • 5
  • 3
  • What do you mean by "how do I get the droppable element in which the draggable element currently resides on drag event"? Do you want to determine the html content of the droppable section or something else? – Yass Mar 03 '16 at 20:01
  • I want a .attr of the droppable section. – Alo Mar 03 '16 at 21:43
  • All of your droppable sections are `div`s. – Yass Mar 03 '16 at 21:59

1 Answers1

1

You can use over

Triggered when an accepted draggable is dragged over the droppable

If that doesn't workout for some reason, try elementFromPoint.

Here's an answer that does it.

Community
  • 1
  • 1
T J
  • 42,762
  • 13
  • 83
  • 138