I can’t seem to figure out how to change the dragged text, without also changing the original text from the element. I want to change the dragged text shown next to the cursor when moving the text, not while dropping it in a dropzone or when dragging it over a DOM, but while dragging it anywhere.
function drag(dragevent) {
dragevent.target.innerHTML = 'bar';
dragevent.dataTransfer.setData("text", dragevent.target.id);
dragevent.target.style.color = "green";
}
<div id="div1">
<span id="drag" draggable="true" ondragstart="drag(event)">drag me</span>
</div>
<div id="div2"></div>
2
Answers
Got it work by altering Dimava's answer a little: