views:

54

answers:

2

Hi,

I have got a table with several rows and columns. I have a span in one of the td which I want to drag. I can drag that span and can get the ID of the td where the span lies but I can anyone tell me how can I get the ID of the td where I drop that span. Now I can get the ID in firefox using event.originalTarget.id of the drop event, but unable to get it in IE.

Thanks, Junaid

A: 

In IE you should be able to use document.elementFromPoint(x, y):

element.ondrop = function (e)
{
    var event = e || window.event;
    var droppedOn = event.originalTarget;
    if (!droppedOn)
    {
        var prevDisplay = element.currentStyle.display;
        element.runtimeStyle.display = "none";
        droppedOn = document.getElementFromPoint(event.clientX, event.clientY);
        element.runtimeStyle.display = prevDisplay;
    }

    alert("Dropped on "+droppedOn.id);
    // rest of code...
}
Andy E
A: 

@Andy: Thanks but your solution didn't work. I had to used droppable to get the ID of the element where the other element is dropped. btw, I am loving jquery

wildanjel