Image switching with <a>
This program shows how to switch an image using the <a>
tag.
Programming Issues
This example is identical to our previous example except that instead of calling the function via the
onclick
event, we call it by specifying it as the target in the <a>
tag enclosing the image in the HTML
document, like so: <a href="javascript:changeImage()">
. In this way we can see how we can call JavaScript
functions directly from the href
attribute of the <a>
HTML tag.
Note: for simplicity, this example does not use image pre-caching.