Drag and Drop: What to Drag - ondragstart and setData()

function drag(ev) {
  ev.dataTransfer.setData("text", ev.target.id);
}
  • Specify what should happen when the element is dragged.
  • The ondragstart attribute calls a function, that specifies what data to be dragged.
  • The dataTransfer.setData() method sets the data type and the value of the dragged data.

Related concepts

What to Drag - ondragstart and setData()

Drag and Drop: What to Drag - ondragstart and setData() — Structure map

Clickable & Draggable!

Drag and Drop: What to Drag - ondragstart and setData() — Related pages: