jQuery(document).ready(function ($) { $(function() { //caches a jQuery object containing the header element var logo = $(".logo"); var header = $("#Header"); $(window).scroll(function() { var scroll = $(window).scrollTop(); if (scroll >= 150) { logo.addClass("logo-shrink"); header.addClass("translucent"); } else { logo.removeClass("logo-shrink"); header.removeClass("translucent"); } }); }); });