Please tell me why this function does not work correctly. It adds a class only after manually changing the screen width, and if the screen width is already less than 640px, then after updating the page, the class is added only if you change the screen width again.
$(document).ready(function() { $(window).resize(function() { if ($(window).width() <= '640'){ $('.header__navigation-img').on('click', function(){ $('.header__nav').toggleClass('header__nav-active'); }) } else { $('.header__nav').removeClass('header__nav-active'); } }); }
resizefunction, and you need this check to be in thereadyfunction - Sergey Glazirin