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

215
Vistas
the div doesn't come back to its place when the div the window is resized

the div moves without problem below 768, but when I resize above it does not return to its original place.

    jQuery(document).ready(function($) {
    $(window).resize(function(){
   if ( $(window).width() < 768) {
        $('#div_block-61-89').detach().prependTo('.offcanvas-inner');
    };
    });
});

any help please

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

0

What you need is store original position of the element before it's moved and than restore it to that position if window size is less than 768

jQuery(document).ready(function($) {
  $(window).resize(function() {
    const div = $('#div_block-61-89');
    const domPos = div.data("domPos");

    if ($(window).width() < 768) {
      if (!domPos) //store position
        div.data("domPos", {el: div.next()||div.parent(), func: div.next() ? "before" :"append"});

      div.prependTo('.offcanvas-inner');
    }
    else if (domPos) //less than 768
    {
      //restore position
      domPos.el[domPos.func](div);
      //remove stored position 
      div.data("domPos", null);
    }
  }).trigger("resize");//check resize on startup
});
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