I am currently working on creating an image that can be clicked to cycle through different images all within the same frame. While I have managed to get it to work, I am facing a limitation where it only responds to one click.
count = 1;
function myFunction(a, b, c) {
if (count === 1) {
document.getElementById("johnnycashpicscroll").src = b;
}
if (count === 2) {
document.getElementById("johnnycashpicscroll").src = c;
}
if (count === 3) {
document.getElementById("johnnycashpicscroll").src = a;
}
if (count === 3) {
count = 1;
}
}
h1 {
font-size: 50px;
font-family: sans-serif;
position: relative;
bottom: 130px;
left: 120px;
}
#topleftimg {
width: 100px;
height: 120px;
top: 100px;
}
hr {
position: relative;
bottom: 115px;
}
button {
margin-left: 20px;
margin-right: 20px;
width: 120px;
height: 60px;
font-family: sans-serif;
font-size: 19.5px;
font-weight: bold;
}
#button1 {
margin-left: 50px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
</head>
<body>
<img id="topleftimg" src="https://th.bing.com/th/id/OIP.uSeMc9l3nH-tNFb-N2KrrgAAAA?w=155&h=195&c=7&r=0&o=5&pid=1.7" alt="Johnny Cash">
<h1>Johnny Cash<button id="button1">Home</button><button>Childhood</button><button>Career</button><button>Challenges</button><button>Legacy</button></h1>
<hr />
<img src="JohnnyCashPic1.jfif" alt="" height="155" width="100" id="johnnycashpicscroll" onclick='myFunction("JohnnyCashPic2.jfif", "JohnnyCashPic3.jfif", "JohnnyCashPic1.jfif")'>
</body>
</html>
If you're wondering, I'm developing a Johnny Cash informational website for a school project.