ZeroShade Posted July 31, 2007 Share Posted July 31, 2007 I have an image. If the user were to click on that image i need it to appear in another image. And then if the user were to click on another image, it takes its place. How can I go about doing this? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 31, 2007 Share Posted July 31, 2007 If you have an id for the target image, you can change the source of it using the src property.document.getElementById("target_image").src = "new_image.jpg"; Link to comment Share on other sites More sharing options...
Synook Posted August 1, 2007 Share Posted August 1, 2007 Like this: <script type="text/javascript"> function changeimage() { image = document.getElementById("target_image"); if (image.src == "image_1.jpg") { image.src = "image_2.jpg"; } else if (image.src == "image_2.jpg") { image.src = "image_3.jpg"; } //Etc. }</script><img id="target_image" src="image_1.jpg" onclick="changeimage()" /> Link to comment Share on other sites More sharing options...
ZeroShade Posted August 1, 2007 Author Share Posted August 1, 2007 I think I can modify it to what I have. Thanks!! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.