javascript - How to make an image change into others on click? -


I'm trying to create a minimum clickable "slideshow". So far, I have only changed the image change to another. But I want to add it to other images. I tried to add other ifs and elses on javascript but it does not work (i am a noob ...) how can i do this? I want to click Jat and change the picture. This is my code so far:

  & lt; Div & gt; & Lt; Img alt = "" src = "1.jpg" id = "imgClick and Replace" onclick = "changeImage ()" /> & Lt; / Div & gt; & Lt; Script language = "javascript" & gt; Changemage function () {if (Dokyumentkgetelementbyid ( "Imgklikkndchange"). Src = "Lkjpg") {Dokyumentkgetelementbyid ( "Imgklikkndchange"). Src = "2.jpg"; Document.getElementById ("imgClickAndChange") Src = "3.jpg"; }} & Lt; / Script & gt;   

Thanks!

If you want to cycle through those images, I create an array and its elements Swap the position:

  var imgs = ["2.jpg", "3.jpg", "1.jpg"]; Function change image () {document.getElementById ("imgClickAndChange"). Src = IMGS [0]; Imgs.push (imgs.shift ())}   



Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -