Home  >  Article  >  Web Front-end  >  How to set css in js to hide

How to set css in js to hide

青灯夜游
青灯夜游Original
2021-04-21 16:06:033572browse

Implementation method: First use the "document.getElementById("id value")" statement to obtain the specified element object; then use the "element object.style.display="none"" statement to control the css and achieve hiding Effect.

How to set css in js to hide

The operating environment of this tutorial: windows7 system, javascript1.8.5&&CSS3 version, Dell G3 computer.

Use js to hide or show css

Known:

<div class="login1" id="login">页面ID为login的元素</div>
<div class="login2" id="regist">页面ID为regist的元素</div>

Code:

<script>
document.getElementById("login").style.display = "none"; //(login为需要隐藏的页面ID)
document.getElementById("regist").style.display = "block" //(regist为需要显示的页面ID)
</script>

Rendering:

How to set css in js to hide

[Recommended learning: javascript advanced tutorial]

The above is the detailed content of How to set css in js to hide. 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