 <p>Right off hand it looks like you're trying to reference the images and container in your JavaScript before the document is loaded. Try moving your script tag with code after (or right before) the closing <code>&lt;/body&gt;</code> tag.</p> <p>Because the document hasn't fully loaded, the DOM API in JavaScript can't yet access those elements if your JavaScript is in the head.</p>