What is a data type in HTML 5 if I need to drag a div into another div?

in the JS function below, the data type is set to "text", but this does not work because I'm looking at a drag and drop div. Is there any way around this? or data type?

function drag(ev) { ev.dataTransfer.setData('Text', ev.target.id); }

Many thanks.

0
source share
1 answer

Mozilla recommends application/x-moz-node for dragging nodes in a document, although this will obviously only work in Gecko-based browsers. This is simpler and generally more compatible with setting the link to the element as text, as you already did, and then using the link to capture the element in the drop event and move it to the code in the right place.

+1
source

Source: https://habr.com/ru/post/926856/


All Articles