Home > Web Front-end > JS Tutorial > body text

How to set css invisible in js

藏色散人
Release: 2023-01-03 09:23:45
Original
2725 people have browsed it

How to set CSS invisible in js: 1. Completely hide the component by setting the display attribute; 2. Realize the component is only hidden by setting the visibility attribute, but affecting the layout; 3. Realize physical transparency by setting opacity Just be invisible.

How to set css invisible in js

#The operating environment of this tutorial: Windows 7 system, Dell G3 computer, css3 version.

There are three ways to set the component invisible via JavaScript: display, visibility, opacity

Set the display attribute

$('#id').css('display','none');  组件完全隐藏,不占用显示时占用的位置
$('#id').css('display','block');
Copy after login

Set the visibility attribute

$('#id').css('visibility','visible');  
$('#id').css('visibility','hidden');   组件仅仅隐藏,依旧影响布局
Copy after login

Set the transparency

$('#id').css('opacity','0');  仅仅是物理上的不可见
Copy after login

Recommended: "js Basic Tutorial"

The above is the detailed content of How to set css invisible in js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
js
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!