I am trying to have a button make an image appear when you press them, then hide them when you press the same button. (3 different images and 3 different buttons in my code). In the code I make the images appear, but I don't know how to make the same buttons hide the images.
function image1() {
document.getElementById("image1").src = "image1.jpg";
}
function image2() {
document.getElementById("image2").src = "image2.jpg";
}
function image3() {
document.getElementById("image3").src = "image3.jpg";
}
<button onclick="image1()">image1</button>
<img src="" id="image1">
<button onclick="image2()">image2</button>
<img src="" id="image2">
<button onclick="image3()">image3</button>
<img src="" id="image3">