How to return the block to its original position after the page loads, if the condition does not work?
function windowSize() { if ($(window).width() <= '767') { $("#cart").appendTo("#mobile-cart"); } } $(window).on('load resize', windowSize); That is, if you increase the width of the browser window, then #cart must be removed from #mobile-cart and returned to its original in .header-cart .
else { $("#cart").appendTo(".header-cart"); }else { $("#cart").appendTo(".header-cart"); }? - Regentelse, then braces are optional.else $("#cart").appendTo(".header-cart");equivalent toelse { $("#cart").appendTo(".header-cart"); }else { $("#cart").appendTo(".header-cart"); }. - Regent