170
rated 0 times
[
176]
[
6]
/ answers: 1 / hits: 27412
/ 9 Years ago, sat, december 5, 2015, 12:00:00
<!DOCTYPE html>
<html>
<body>
<img id = imageOne src = circleRed.png onclick = changeColor()/>
<script>
var image = document.getElementById(imageOne);
function changeColor() {
if (image.src == circleRed.png) {
image.src = circleBlue.png;
} else {
image.src = circleRed.png;
}
}
</script>
</body>
</html>
This whole program may seem to work but no. I'll just be able to change the color of my image once. After clicking for the second time, nothing happens. What I mean is that I can only change the color from Red to Blue.
Could you please help me figure out why?
More From » html