December 2013
Intermediate to advanced
384 pages
9h 54m
English
. . . jQuery . . . $("img").on("click", function(){ $("#top").fadeToggle(2000); }); . . . HTML . . . <img id="bottom" src="lake.jpg" /> <img id="top" src="volcano.jpg" />
You cannot directly animate the transition from one image to another so that one image is fading in while the other is fading out. The way to overcome that challenge is to have two images—one on top of the other—and then animate fading the top one out.
The following code does just that. There are two images with fixed positioning. When you click on the top image, it toggles the image opacity in and out, as shown in Figure 12.2.
01 <html> 02 <head> 03 <title>Python ...
Read now
Unlock full access