Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
Drag and drop makes dissapear all the div

As u can see, images swap positions correctly but when i want to drag the image in the blank space (i want to make this image the latest in the row) it crashes.

 function allowDrop(ev) {
   ev.preventDefault();
}

function drag(ev) {
   ev.dataTransfer.setData("text", ev.target.id);
}

function drop(ev) {
   ev.preventDefault();

   var id = ev.dataTransfer.getData("text");
   var element = document.getElementById(id)
   var div = document.getElementById(id).parentNode;
   var clonedHeart = document.getElementById(ev.target.id).cloneNode(true);

   ev.target.parentNode.insertBefore(element, ev.target.id.nextSibling)
   document.getElementById(ev.target.id).remove();
   div.appendChild(clonedHeart);

   ev.dataTransfer.clearData();
}

Any help? Ty in advance. Here u got the JSFiddle

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!