- By Rob Miles
An image display program
<img src="seaside1.JPG" id="pageImage"></p>
var pic = document.getElementById("pageImage"); pic.src="fairground.JPG";
These two statements get a reference to the image and then set the src attribute of the img to refer to the image fairground.jpg. This will update the image displayed by the browser. Note that this is a repetition of a pattern that you’ve seen several times now. A program obtains a reference to a display element and then makes changes to it. You can find a complete image picker program in the Ch02-12 Image Picker example.