Home  >  Article  >  Web Front-end  >  What method is used to hide elements in js

What method is used to hide elements in js

little bottle
little bottleOriginal
2019-05-17 09:54:579453browse

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.

What method is used to hide elements in js

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn