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

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -