Navbar that adds and removes classes I've written some jQuery for my navbar, but it's super sloppy and I'm always trying to write better code.

$(function(){
    $(window).scroll(function(){
    var sT = $(this).scrollTop();
    if (sT &gt;= 70) {
        $('.navbar').addClass('navbar-switch')
        $('.navbar .scroll-link').addClass('navbar-link-switch')
        $('.navbar .logo').addClass('logo-adjust')
        $('.navbar hr').addClass('hide')
        $('.navbar .navbar-collapse').addClass('border')
    } else {            
        $('.navbar').removeClass('navbar-switch')
        $('.navbar .scroll-link').removeClass('navbar-link-switch')
        $('.navbar .logo').removeClass('logo-adjust')
        $('.navbar hr').removeClass('hide')
        $('.navbar .navbar-collapse').removeClass('border')
    }
    })
})


My goal is that, when the user scrolls pass a certain limit, my navbar removes certain classes and adds certain classes.
Is hard to evaluate without the html  but, considere introduce toggleClass.

$element.toggleClass(className, condition);


http://api.jquery.com/toggleClass/

If your jQuery version doesn´t allow it, you can introduce as a separate function:

function toggleClass($element, class, condition) {
   condition ? $element.addClass(class) : $element.removeClass(class);
}


and the full solution: http://jsfiddle.net/cbhvteon/1/