jQuery makes dynamic image swapping a peace of cake. All you need to do to replace your image with another one is to replace its
src attribute. The browser will take care of the rest.
Here is an example:
In the code above we are:
- Selecting an image to be replaced;
- Changing its
srcattribute to the new replacer image’s URL.
To avoid page jumping and improve user experience it is a good idea to preload your images before you swap them.