Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

200
Vistas
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 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda