title: Replacing image based on screen size with Jquery
body: <p>I'm attempting to change an image src based on the screen size. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>       $(document).ready(function() {
      $(function() {
        if($(window).width() &lt; 568) {
          $("#crewimage").each(function() {
            $(this).attr("src", $(this).attr("src").replace("resources/images/thecrew.png", "resources/images/thecrewmobile.png"));
          });
        } else if ($(window).width() &gt;= 568) {
          $("#crewimage").each(function() {
            $(this).attr("src", $(this).attr("src").replace("resources/images/thecrewmobile.png", "resources/images/thecrew.png"));
          });
       }
      });
     });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div id="crew-content"&gt;
       &lt;img id="crewimage" src="resources/images/thecrew.png" alt="Header Image"&gt;&lt;/img&gt;
   &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>My logic seems solid. I'm not sure why its not functional.</p>
  
  <p>Thanks for the help in advance.</p>