opacidade do css jQuery

O que se passa? Eu quero mudar a opacidade se #nav .drop For display:block;

jQuery(document).ready(function(){
    if (jQuery('#nav .drop').css('display') === 'block') {
        jQuery('#main').css('opacity') = '0.6';
    }
});
Author: Alexis Wilke, 2013-05-07

4 answers

jQuery('#main').css('opacity') = '0.6';

Deve ser

jQuery('#main').css('opacity', '0.6');

Actualização:

Http://jsfiddle.net/GegMk/ Se escrever no campo de texto. Clique fora, a opacidade muda.

 99
Author: rdp, 2013-05-07 13:57:07

Tenta com isto:

jQuery('#main').css({ opacity: 0.6 });
 25
Author: Alarid, 2013-05-07 13:56:50

Tenta isto:

jQuery('#main').css('opacity', '0.6');

Ou

jQuery('#main').css({'filter':'alpha(opacity=60)', 'zoom':'1', 'opacity':'0.6'});

Se quiser apoiar IE7, e assim por diante.

 15
Author: ed1nh0, 2014-04-23 17:31:47

Tenta usar .animar em vez de .css ou mesmo só na opacidade e ir embora .css no ecrã?? may b

jQuery(document).ready(function(){
if (jQuery('#nav .drop').animate('display') === 'block') {
    jQuery('#main').animate('opacity') = '0.6';
 0
Author: hoppie, 2015-12-07 06:53:02