4 A JAVASCRIPT IMAGE GALLERY

It's time to put to the Document Object Model to work. This chapter will show you how to make an image gallery using JavaScript and the DOM.

  • Begin with a well-marked-up document
  • Write a JavaScript function to display a requested image
  • Trigger the function from within the markup
  • Expand the function using some new methods

There are a number of ways to put a gallery of images online. You could simply put all the images on one web page, for example. However, if you want to display more than a handful of images, the page is going to get big and bloated fairly quickly. The weight of the markup by itself might not be all that much, but the combined weight of the markup and images can result in a hefty download. Let's ...

Get DOM Scripting: Web Design with JavaScript and the Document Object Model now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.