jQuery CSS 不透明度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16420874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery CSS Opacity
提问by Mike
What's wrong? I want to change the opacity if #nav .drop
is display:block;
怎么了?如果#nav .drop
是,我想改变不透明度display:block;
jQuery(document).ready(function(){
if (jQuery('#nav .drop').css('display') === 'block') {
jQuery('#main').css('opacity') = '0.6';
}
});
回答by rdp
jQuery('#main').css('opacity') = '0.6';
should be
应该
jQuery('#main').css('opacity', '0.6');
Update:
更新:
http://jsfiddle.net/GegMk/if you type in the text box. Click away, the opacity changes.
http://jsfiddle.net/GegMk/如果您在文本框中输入。点击,不透明度改变。
回答by Alarid
Try with this :
试试这个:
jQuery('#main').css({ opacity: 0.6 });
回答by ed1nh0
Try this:
尝试这个:
jQuery('#main').css('opacity', '0.6');
or
或者
jQuery('#main').css({'filter':'alpha(opacity=60)', 'zoom':'1', 'opacity':'0.6'});
if you want to support IE7, IE8and so on.
如果你想支持IE7,IE8等等。
回答by hoppie
try using .animate instead of .css or even just on the opacity one and leave .css on the display?? may b
尝试使用 .animate 而不是 .css 或者甚至只是在不透明度上使用 .css 并将 .css 留在显示器上??也许吧
jQuery(document).ready(function(){
if (jQuery('#nav .drop').animate('display') === 'block') {
jQuery('#main').animate('opacity') = '0.6';