I'm trying to switch between two images every time they're clicked.
I've tried creating a script that first gets the image with var image = document.getElementById(id);
and then checks which image is currently active with if (image.src == "a.png")
but this never returns true.
When I print it with console.log(image.src)
the whole source appears:
file:///C:/Users...../a.png
The idea was to have something like this:
var image = document.getElementById(id);
if (image.src == "a.png") {
image.src = "b.png";
}
else {
image.src = "a.png";
}
}
What am I doing wrong here?