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
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
});