HTML5 Drag & Drop Change icon/cursor while dragging

Alex Ivasyuv picture Alex Ivasyuv · Apr 12, 2012 · Viewed 81.3k times · Source

I'm wondering how to change during dragging (dragover/dragenter) icon/cursor when I dragenter for example to deny or allow section. Of course, I can move with cursor a part of DOM positioned absolutely, but I'm interested in native HTML5 solution.

Thanks!

Answer

zupa picture zupa · May 14, 2012

You are after dropEffect:

Initialize it in dragstart:

event.dataTransfer.effectAllowed = "copyMove";

Update it in dragenter:

event.dataTransfer.dropEffect = "copy";