How to Hide a control but keep its space occupied?

Usually, to hide a control or a block in HTML, we can use the following JavaScript to set the style of the control or the block,

document.getElementById(“”).style.display=”none”;

or apply the following  css,  

.some-css-name

{

   display:none

But it will remove the space occupied by the control as well. If we want to keep the space, but only want to hide the control, we can use the following way,

document.getElementById(“”).style.visibility=”hidden”;

or

.some-css-name

{

   visibility:hidden;

}

BTW, the reverse function of the above is as below,

document.getElementById("").style.display="inline"

document.getElementById("").style.visibility="visible";

原文地址:https://www.cnblogs.com/fangwenyu/p/1608562.html