So I\'m new with JavaScript (this is actually my first attempt to make something work) and I\'m having a bit of trouble. I thought I had enough knowledge to make this work,
Try this!
function changeimage() { var image = document.getElementById('imagem'); if (image.src.match("img")) { for(i = 1; i <= 3; i++) { image.src = "img/image2"+i+".png"; } } else { image.src = "img/image1.png"; } }