• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

129
Views
I want my todo list items sorted even if I change the order myself

I have this code written and my customer wants this lists item's inner HTMLs to stay the same even if we change the places.

For example, if I go drag first element to the third place, the animation will occur but then, the list will stay the same as "Firs -> Second -> Third".

Any thoughts on how can I do it using JavaScript code?

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Drag & Drop Element</title>
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.10.2/Sortable.min.js"></script>
</head>
<body>
  <div class="wrapper">
    <div class="item first">
      <span class="text">First element</span>
      <i class="fas fa-bars"></i>
    </div>
    <div class="item second">
      <span class="text">Second element</span>
      <i class="fas fa-bars"></i>
    </div>
    <div class="item third">
      <span class="text">Third element</span>
      <i class="fas fa-bars"></i>
    </div>
  </div>
  <script>
    const dragArea = document.querySelector(".wrapper");
    new Sortable(dragArea, {
      animation: 350
    });
  </script>
</body>
</html>
about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error