Karla Og
Karla Og

Reputation: 1

Drag And Drop Vanilla JS with a generated div

Can someone explain to me how you can make a div dragable when the div itself is created only after you clicked on a button that will add the div like a to do list ? i

Upvotes: 0

Views: 285

Answers (1)

John Halbert
John Halbert

Reputation: 1350

MDN has good documentation on how this works in vanilla js. You could start with something like this: https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API.

It's unclear exactly what you're asking, though. How exactly do you want this div to appear - rendered somewhere on the page after clicking the button, then later dragged, or immediately in a dragging state, or something else?

The drag/drop API will support both of what I described above, but getting each to work requires different approaches. Clarification here would help.

Upvotes: 1

Related Questions