you can set visibility through style
document.getElementById('idofelement').style.display("none"); //hide element
document.getElementById('idofelement').style.display(""); //display element
css display will make the element invisible and also hide it from the page so elements will shift as if the element you hid was gone from the page
document.getElementById('idofelement').style.visibility("hidden"); //hide element
document.getElementById('idofelement').style.visibility("visible"); //display element
css visibility will make the item invisible, but it will still hold it's place on the page
for example if you had 3 images, and you used css display property to hide the middle image, the third image would move to be next to the first image, as if there was no 2nd image there. If you used visibility to hide the middle image, then the middle image would disappear and it would look like there was an empty space the size of the middle picture between pictures 1 and 3