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

How to set css in js to hide

青灯夜游
Release: 2023-01-05 16:10:22
Original
3594 people have browsed it

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>
Copy after login

Code:

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

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!

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template