I have a button that dynamically creates an object and makes it “draggable” using the following code using jquery:
createNewDiv(divId); <--local function that creates a new div with id=divId
$("#"+divId).draggable();
which makes the element with the Id = divId element draggable (thanks to jquery libs), so any newly created element can be dragged and dropped anywhere on the page
Now suppose I create the elements A, B and C, they are all dragged and I drag n 'drop one on top of the other (so that C stays “over” B, and B stays “over” A, like paper sheets stacked one over another)
Is there a way to determine which elements are below each of them? For example, when you hover over C, does it return “element B and element A below ..” (both of them) or when you hover B, does it return “element A below”?
I have explored several methods, such as elementFromPoint () or the .droppable () method from jquery, but I cannot return - several elements - below any other (e.g. C to return both A and B below)
Another way I could imagine using this code is to override .droppable () and call it recursively, but at the moment I don't see how to do it. For example, when:
a) Dropping A, nothing is displayed (without the item below)
b) Drop B over A - “B on {A}” is displayed
c) Drop C over B - “C on {B, A}” (C finds B, which B finds A)
jQuery Javascript