View Full Version : Changing image with onclick

10-02-2008, 01:54 PM
Hey there,

I am not very into the javascript programming, so I cant make this (simple) thing work...

suppose there are two images, img1 and img2, when img1 is clicked on it must change to img1clicked, after that when img2 is clicked on it must change to img2clicked AND img1clicked must change back to img1.

I cant make that last thing work... fitst clicking and after that clicking img2 both images will change to the right images.


10-02-2008, 03:33 PM
i am asking a similar question-ish but at least the image swap bit is working.

if your image 1 has an id="img1" and image 2 id="img2".

then in the img src="folder/img1.jpg" id="img1" onClick="this.src='folder/img1clicked.jpg'"

img 2: img src="folder/img2.jpg" id="img2" onClick="this.src='folder/img2clicked.jpg';img1.src='folder/img1.jpg'"

i think. i can't do javascript either. but it might work. fiddle with it.

10-02-2008, 04:24 PM

I just tried it, and it is perfect for the purpose i had in mind!!

thank you very much :D