Updating an image within a page
jQuery allows the developer to dynamically change images on a web page. This recipe will show you how to do this and also show you how to use a timestamp in order to prevent the browser from using a cached image, which can often be a problem when swapping images dynamically in this way.
For this recipe, you are going to need four different images. Ensure that you have four small images named
How to do it…
To understand how jQuery can be used to change an image, complete each of the following steps:
- Create a file named
recipe-8.htmlwithin an easily accessible directory, and add the following HTML code to this file:
<!DOCTYPE html> <html> <head> <title>Change ...