First of all, I have basically no knowledge on how to write JavaScript, so my problem might be quite simple to answer, but I've done some research and I didn't find anything yet. I'd like to know how to change my image on click then back to original image when another image is clicked, not the same one.
In my research, I've found how to go from one image to another on click and I found this :
function changeImage(img){
if(img.src=="resources/items/original_image.png"){
img.src="resources/items/icon2blue.png";
}else {
img.src="resources/items/original_image.png";
}
}
which works perfectly, but is not really want I want to do. And I don't know how to modify this to arrive where I want to go haha.
I found another post on the forum with the same problem but couldn't make any of the solution answered work. thanks to anybody who helps :)
From how I understand the question, there are two images, and when the main/original image is clicked, that same one should be changed to another image, but when another image is clicked, then the original image should be changed from the
icon2blue.pngto the original image it was.Okay assuming your first image is
and the second one is
Your JavaScript file will be as so:
Hope I answered your question. If I misunderstood something, let me know :)