I am trying to manipulate the DOM when resizing with this code

$(window).resize(function() { var windowWidth = $('body').innerWidth(); var elem=$('.Head').append(); if(windowWidth < 450){ if(elem.length<1){ $('.Head').append('<--->') } $('.rem').hide(); } else{ $('.Add').hide(); $('.rem').show(); } }); Но при изменении размера страницы без перезагрузки часть кода не выполняется,пожалуйста подскажите как сделать правильно 

here is a site for greater clarity http://f0236766.xsph.ru/

    1 answer 1

    Wrap everything in

     $( window ).resize(function() { }); 
    • thanks, it helped! - Kirill Chetvertkov
    • you can still tell why this condition is not satisfied ($ ('. append'). length <1) and here it is $ ('. append'). remove () ;? I updated the site - Cyril Chetvertkov
    • You do not have .append elements to delete something. Proceeding from the last judgment, the condition is always true - it is executed when the window width is less than 450 (you yourself indicated) - Aleksey
    • I changed the code in my question, but now this if (elem.length <1) condition is not met, tell me what I am doing wrong, please - Cyril Chetvertkov