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

166
Vistas
HTML5 Drag and Drop restrictions

Pseudo code

DIV1
-- IMG 1
-- IMG 2

DIV2
-- IMG 3
-- IMG 4

What i'm intending on happening is that images in DIV1 and DIV2 should be able to be swapped...but only one SWAP can happen at a time. if 1 and 3 are swapped then I can't swap 3 with 4 only after I replace 1 and 3 can I make another swap...

Also I should never be able to swap within in a div..

I understand the basics of HTML drag and drop I'm just not sure how to put restructions on the swapping. I don't need CODE however just a path to get started.

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Set a data attribute on each image containing a reference to the parent Div.

Loop through the images on interaction, if you find an image with a parent attribute that doesn't match it's actual current parent then disable the drag.

Have a look at Jquery Sortable Lists That has much of the functionality you are looking for out of the box, and allows you to test for target and origin which would allow you to implement no swapping within div.

about 4 years ago · Juan Pablo Isaza Denunciar
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