i have a code that shows a fade in image onload.
i have 2 other images and needs to be replaced when i click on the buttons "one" and "two" in the same place. pl help. attached images in zip.
It looks like you've got it all setup except for the part where you replace the image with a new image. I would add that into the initImage function, like below:
(You might also want to preload the images, so they are loaded before they start fading in)
The easiest thing to do is stick a "preload" div at the bottom of your document like in the first example below. You can also use a function, like the second example.
<!-- Example 1 --><div style="display:none" id="preloads"> <img src="image1.src" alt="" /> <img src="image2.src" alt="" /></div><!-- Example 2 --><script>function preload() {var d=document;if(d.images){ if(!d.imgs) d.imgs=new Array(); var i,j=d.imgs.length,a=preload.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.imgs[j]=new Image; d.imgs[j++].src=a[i]; } }}//in body.onload ...preload("image1.jpg", "image2.jpg", ...);</script>
(You might also want to preload the images, so they are loaded before they start fading in)
Open in new window