title: Cannot set property 'src' of null
body: <p>I am trying to rotate an image using javascript  and I was trying some code I found on adobes website that does what I was looking for. When I run it it gives me the error: Uncaught TypeError: Cannot set property 'src' of null </p>
  
  <p>It keeps repeating every 5 second interval which is the amount of time between each image</p>
  
  <p>Here is the javascript:</p>
  
  <pre><code> (function () {
          var rotator = document.getElementById('rotator');  // change to match image ID
          var imageDir = 'images/';                          // change to match images folder
          var delayInSeconds = 5;                            // set number of seconds delay
          // list image names
          var images = ['image2.jpg', 'image3.jpg', 'image4.jpg', 'image1.jpg'];
  
          // don't change below this line
          var num = 0;
          var changeImage = function () {
              var len = images.length;
              rotator.src = imageDir + images[num++];
              if (num == len) {
                  num = 0;
              }
          };
          setInterval(changeImage, delayInSeconds * 1000);
      })();
  </code></pre>
  
  <p>and here is the html for the image:</p>
  
  <pre><code>&lt;img src="images/image1.jpg" alt="rotating image" width="400" height="300" id="rotator" /&gt;
  </code></pre>
  
  <p>It shows the image1.jpg, but does not rotate it. Is there something blatantly obvious that I am not seeing? Wouldn't surprise me!</p>
  
  <p>Thanks to anyone that can offer advice.</p>