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

How to set css invisible in js

藏色散人
藏色散人Original
2021-02-19 09:07:102737browse

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');

Set the visibility attribute

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

Set the transparency

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

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!

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