I’m working on this drag and drop application with jquery/javascript, and I’m having to use a balance of the two to accomplish what I want.
var drop = document.elementFromPoint($(this).offset().left, $(this).offset().top);
what I’m trying to do with this code here is to get the element that my draggable is trying to be dropped in (is currently hovering over). This, however, will always return my draggable, as opposed to the the table cell (td) underneath it.
Since I know I am looking for a td element, is there a way to set var drop to be something like:
var drop = document.elementFromPoint(x, y, 'td')?
Or is there a better way to go about doing this?
Since
document.elementFromPointreturns the topmost element, you’ll need to temporarily set your draggable todisplay:noneorpointer-events:noneto find elements below it. I’ve created a gist below that returns a list of all elements at a given point.try
or
then
Using the gist below: https://gist.github.com/2166393