Hiding elements in js can be achieved using the style attribute in html. Specific methods include: [style.display="block"], which means the control is visible; [style.display="none"], which means the control is invisible.
There are two ways to use JS to control the display and hiding of page controls. The two methods respectively use two attributes in the HTML style.
The control is visible when style.display="block" or style.visibility="visible";
The control is not visible when style.display="none" or style.visibility="hidden".
The difference is that "display" not only hides the control, but also the hidden control no longer occupies the position occupied when displayed, while the control hidden by "visibility" only sets the control to be invisible, and the control still occupies the original position. Location.
The above is the detailed content of What method is used to hide elements in js. For more information, please follow other related articles on the PHP Chinese website!