title: Change div Background jquery
body: <p>I'm not sure what I'm doing wrong. I'm trying to get the background image of my div to change over time. I got the jQuery function from this site but its not working for me. Any clue what I'm doing wrong.</p>
  
  <h2>jQuery</h2>
  
  <pre><code>$(window).load(function () {
      var images = ['wave_01.png', 'wave_02.png'];
      var i = 0;
  
      function changeBackground() {
          $('main').css('background-image', function () {
              if (i &gt;= images.length) {
                  i = 0;
              }
              return 'url(' + images[i++] + ')';
          });
      }
      // Call it on the first time
      changeBackground();
      // Set an interval to continue
      setInterval(changeBackground, 3000);
  });
  </code></pre>
  
  <h2>HTML</h2>
  
  <pre><code>&lt;div class="main"&gt;&lt;/div&gt;
  </code></pre>
  
  <h2>CSS</h2>
  
  <pre><code>.main {
      background-image: url(../images/wave_01.png);
      background-repeat:no-repeat;
      background-size: 100% 40%;
  }
  </code></pre>