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

218
Views
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 answers
Answer question

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 Report
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!