javascript - How can I replace the content of a div when I drag and drop -
When I leave, how can I drag and change content; in this instance:?
function allowDrop (ev) {ev.preventDefault (); } Function drag (ev) {ev.dataTransfer.setData ("text", ev.target.id); } Function drop (ev) {ev.preventDefault (); Var data = ev.dataTransfer.getData ("text"); Ev.target.appendChild (document.getElementById); }
Try it out:
Function drop ( Ev) {ev.preventDefault (); Var data = ev.dataTransfer.getData ("text"); Var s = document.getElementById (data); Ev.target.appendChild (s); Ev.target.src = s.src; } Update your Drop Function like this Basically, you have to update the source of the dropped IMG, it works for now.
Comments
Post a Comment