Home > Article > Web Front-end > How to set css invisible in js
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.
#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!