Jquery resize or scroll function not working?
<pre><code>function navbarBackground() {
    if ($(window).width() &gt; 639) {
        $(document).scroll(function () {
            if ($(window).scrollTop() &gt; 60) {
                $('.navbar').addClass('back', 250);
            } else {
                $('.navbar').removeClass('back', 250);
            }
        });
    } else {
        $('.navbar').addClass('back', 250);
    }
}

$(window).resize(function() {
    navbarBackground();
});

$(document).ready(function() {
    navbarBackground();
}
</code></pre>

<p>I need when user scrolls over 60px to add class and remove it if it's scrolled less than 60px only if screen width is more than 639px, and when it shrinks it adds class even if it's not scrolled, and also to do that on resize and window ready. The problem is that my scroll function applies on less than 639px, so when i scroll down and scroll back to top it removes the class but it shouldn't (on small screen). What is the problem?</p>