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

What method is used to hide elements in js

little bottle
Release: 2020-09-15 16:54:53
Original
9556 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template