I'm trying to hide pictures displayed on my website. I've got a list of options where I choose only one picture which I want to show and a button to execute the event. So my issue is that when I press the button, pictures only hide for a moment (I want them to be gone for good). What am I doing wrong?
document.addEventListener("DOMContentLoaded", function () {
var select = document.querySelector(".form-control");
var img = document.querySelectorAll("img");
var submit = document.querySelector("button");
var imgApple = img[0];
var imgUbuntu = img[1];
var imgWindows = img[2];
submit.addEventListener("click", function () {
if (select.value == "Windows") {
imgApple.style.visibility = "hidden";
imgUbuntu.style.visibility = "hidden";
} else if (select.value == "Os X") {
imgApple.style.visibility = "visible";
imgUbuntu.style.visibility = "hidden";
} else if (select.value == "Ubuntu") {
imgApple.style.visibility = "hidden";
imgWindows.style.visibility = "hidden";
}
});
});