I am trying to get the id
of the dragged element. I saw a few examples for JQuery, but could not find a solutions for the Vanilla equivalent.
I tried it with this
, however that seems to give me the document.
event
will give me the dropped containers id
instead.
let dropElements = document.getElementsByClassName('drop');
for (let item of dropElements) {
item.addEventListener('dragover', (event) => {
event.preventDefault();
});
item.addEventListener('drop', (event) => {
event.target.innerHTML = 'Woooop';
});
}
I am thinking that maybe it is not intended to be able to have access to the dragged item, and i must get it via the i.e. dragstart
eventlistener?