What I try to do is that every time I click on the button it shows me the following image. However, it does not work. In some websites they say it does not work because the route (img.jpg) is not correct as a condition, but I do not understand why. Thanks!
function showImage(){
if (document.getElementById('imgLabel1').src == 'img1.jpg')
{
document.getElementById('imgLabel1').src = 'img2.jpg';
}
else if (document.getElementById('imgLabel1').src == 'img2.jpg')
{
document.getElementById('imgLabel1').src = 'img3.jpg';
}
else
{
document.getElementById('imgLabel1').src = 'img1.jpg';
}
}
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="gallery.js"></script>
<link rel="stylesheet" href="styleImg.css">
<title></title>
</head>
<body>
<img id="imgLabel1" src="img1.jpg">
<button id="next" onclick="showImage()">NEXT IMAGE</button>
</body>
</html>