title: Detect when element is less than 100px from top of window, change CSS
body: <p>I'm trying to make it so that when <code>div.projectsgrid</code> is &lt; 100px from the top, jQuery will see if <code>div.selectedwork</code> has css background-color #ffffff. If not, it will set its background-color to #ffffff. Once the user scrolls back up and <code>div.projectsgrid</code> is more than 100px from the top, jQuery will remove the background color. I have the following code, which isn't working:</p>
  
  <pre><code>$(window).scroll(function(e){ 
      var el = $('.selectedwork'); 
      var top = $('#projectsgrid').offset().top;
  
      if ($(top) &lt; 100 &amp;&amp; el.css('background-color') != '#ffffff'){
          $(el).css({'background-color': '#ffffff'});
      }
      if ($(top) &gt; 100 &amp;&amp; el.css('background-color') == '#ffffff'){
          $(el).css({'background-color': ''});
      }
  });
  </code></pre>