Imagine that you'd like several instances of the ImageCaption
class. We'll create a situation where one of the images will have its caption at the top of the image instead of before.
First, modify the HTML markup in such a way that the last image has an ID of
#caption-on-top
.<body> <h1>ImageCaption Script</h1> <p><img src="lake_mead.jpg" width="300" height="201" alt="Lake mead in a speeding car." /></p> <p><img src="clouds.jpg" width="150" height="101" /></p> <p><img id="caption-on-top" src="red_rocks.jpg" width="300" height="201" title="A photo of Red Rock Mountain near Las Vegas, Nevada." /></p> </body>
Next, let's create a class instance of the
ImageCaption
class. This time, we limit the image caption to only the image with the ID of#caption-on-top
. Also, we use one of our options,captionPosition
, to change the default value of'after'
to'before'
.var captionOnTop...