Lo que intento hacer es que cada vez que hago click en el boton me muestre la siguiente imagen. Sin embargo no funciona. En algunas webs dicen que no funciona porque la ruta (img.jpg) no es correcta como condicion, pero no entiendo el por que. Gracias!
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>
src
tenga una ruta completa de la imagen.