Código HTML:
<html> <head> <title>Photo Gallery</title> <script> document.getElementById("photo").style.backgroundImage = "url(1.jpg)"; function changephoto() { if (document.getElementById("photo").style.backgroundImage = "url(1.jpg)"){ document.getElementById("photo").style.backgroundImage = "url(2.jpg)"; } else{ if (document.getElementById("photo").style.backgroundImage = "url(2.jpg)"){ document.getElementById("photo").style.backgroundImage = "url(3.jpg)" } else{ if (document.getElementById("photo").style.backgroundImage = "url(3.jpg)"){ document.getElementById("photo").style.backgroundImage = "url(1.jpg)" } } } } </script> <body> <div id="photo" onclick="changephoto();"></div> </body> </html>
Gracias por adelantado