score:0

There is no object inside event called transfer. One thing you can do is try event.setData(), but I don't think that's what you want either, because the dragstart and drop events are two different event objects.

You can instead have a separate local variable to use. E.g.

var draggedType = null; 

d3.select('img').on('dragstart', function() { 
    var draggedType = d3.select(this).attr('type');
    console.log("Drag starts with "+ draggedType);
});

d3.select('.drop').on('drop', function() {
    d3.event.preventDefault();
    console.log("Drag ends with "+ draggedType);
    // do something with draggedType here

    draggedType = null; // reset draggedType to null when done, just in case
});

Related Query